webpack.config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. const DtsBundleWebpack = require('dts-bundle-webpack');
  4. const CleanWebpackPlugin = require('clean-webpack-plugin');
  5. module.exports = {
  6. context: __dirname,
  7. entry: {
  8. 'babylonjs-materials': path.resolve(__dirname, './legacy/legacy.ts'),
  9. },
  10. output: {
  11. path: path.resolve(__dirname, '../dist/preview release/materialsLibrary'),
  12. filename: 'babylonjs.materials.min.js',
  13. libraryTarget: 'umd',
  14. library: {
  15. root: ["MATLIB"],
  16. amd: "babylonjs-materials",
  17. commonjs: "babylonjs-materials"
  18. },
  19. umdNamedDefine: true
  20. },
  21. resolve: {
  22. extensions: [".js", '.ts']
  23. },
  24. externals: {
  25. babylonjs: {
  26. root: "BABYLON",
  27. commonjs: "babylonjs",
  28. commonjs2: "babylonjs",
  29. amd: "babylonjs"
  30. }
  31. },
  32. devtool: "source-map",
  33. module: {
  34. rules: [{
  35. test: /\.tsx?$/,
  36. exclude: /node_modules/,
  37. use: [
  38. {
  39. loader: 'awesome-typescript-loader',
  40. options: {
  41. configFileName: '../../materialsLibrary/tsconfig.json',
  42. declarationDir: '../../dist/preview release/materialsLibrary/build'
  43. }
  44. }]
  45. }]
  46. },
  47. mode: "production",
  48. devServer: {
  49. contentBase: path.join(__dirname, "dist"),
  50. compress: false,
  51. //open: true,
  52. port: 9000
  53. },
  54. plugins: [
  55. new CleanWebpackPlugin([
  56. path.resolve(__dirname, './src/**/*.js'),
  57. path.resolve(__dirname, './src/**/*.map')
  58. ]),
  59. new webpack.WatchIgnorePlugin([
  60. /\.js$/,
  61. /\.d\.ts$/,
  62. /\.fx$/
  63. ])
  64. ],
  65. watchOptions: {
  66. ignored: [path.resolve(__dirname, './dist/**/*.*'), 'node_modules']
  67. }
  68. }