webpack.config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. {
  26. babylonjs: {
  27. root: "BABYLON",
  28. commonjs: "babylonjs",
  29. commonjs2: "babylonjs",
  30. amd: "babylonjs"
  31. }
  32. },
  33. /^babylonjs.*$/i,
  34. ],
  35. devtool: "souce-map",
  36. module: {
  37. rules: [{
  38. test: /\.tsx?$/,
  39. exclude: /node_modules/,
  40. use: [
  41. {
  42. loader: 'awesome-typescript-loader',
  43. options: {
  44. configFileName: '../../materialsLibrary/tsconfig.json',
  45. declarationDir: '../../dist/preview release/materialsLibrary/build'
  46. }
  47. }]
  48. }]
  49. },
  50. mode: "production",
  51. devServer: {
  52. contentBase: path.join(__dirname, "dist"),
  53. compress: false,
  54. //open: true,
  55. port: 9000
  56. },
  57. plugins: [
  58. new CleanWebpackPlugin([
  59. path.resolve(__dirname, './src/**/*.js'),
  60. path.resolve(__dirname, './src/**/*.map')
  61. ]),
  62. new webpack.WatchIgnorePlugin([
  63. /\.js$/,
  64. /\.d\.ts$/,
  65. /\.fx$/
  66. ])
  67. ],
  68. watchOptions: {
  69. ignored: [path.resolve(__dirname, './dist/**/*.*'), 'node_modules']
  70. }
  71. }