webpack.config.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  4. const CleanWebpackPlugin = require('clean-webpack-plugin');
  5. const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
  6. module.exports = {
  7. context: __dirname,
  8. entry: {
  9. 'babylonjs-inspector': path.resolve(__dirname, './legacy/legacy.ts'),
  10. },
  11. output: {
  12. path: path.resolve(__dirname, '../dist/preview release/inspector'),
  13. filename: 'babylon.inspector.bundle.js',
  14. libraryTarget: 'umd',
  15. library: {
  16. root: "INSPECTOR",
  17. amd: "babylonjs-inspector",
  18. commonjs: "babylonjs-inspector"
  19. },
  20. umdNamedDefine: true
  21. },
  22. resolve: {
  23. extensions: [".js", '.ts', ".tsx"],
  24. },
  25. externals: [
  26. {
  27. babylonjs: {
  28. root: "BABYLON",
  29. commonjs: "babylonjs",
  30. commonjs2: "babylonjs",
  31. amd: "babylonjs"
  32. },
  33. "babylonjs-gui": {
  34. root: ["BABYLON", "GUI"],
  35. commonjs: "babylonjs-gui",
  36. commonjs2: "babylonjs-gui",
  37. amd: "babylonjs-gui"
  38. },
  39. "babylonjs-loaders": {
  40. root: "BABYLON",
  41. commonjs: "babylonjs-loaders",
  42. commonjs2: "babylonjs-loaders",
  43. amd: "babylonjs-loaders"
  44. },
  45. "babylonjs-serializers": {
  46. root: "BABYLON",
  47. commonjs: "babylonjs-serializers",
  48. commonjs2: "babylonjs-serializers",
  49. amd: "babylonjs-serializers"
  50. }
  51. },
  52. /^babylonjs.*$/i
  53. ],
  54. devtool: "source-map",
  55. module: {
  56. rules: [{
  57. test: /\.tsx?$/,
  58. loader: 'awesome-typescript-loader',
  59. options: {
  60. configFileName: '../../inspector/tsconfig.json',
  61. declaration: false
  62. }
  63. },
  64. {
  65. test: /\.scss$/,
  66. use: [
  67. // fallback to style-loader in development
  68. process.env.NODE_ENV !== 'production' ? 'style-loader' : MiniCssExtractPlugin.loader,
  69. "css-loader",
  70. "sass-loader"
  71. ]
  72. }, {
  73. test: /\.css$/,
  74. use: ['style-loader', 'css-loader']
  75. }]
  76. },
  77. mode: "production",
  78. devServer: {
  79. contentBase: path.join(__dirname, "dist"),
  80. compress: false,
  81. //open: true,
  82. port: 9000
  83. },
  84. performance: {
  85. hints: false
  86. },
  87. plugins: [
  88. new HardSourceWebpackPlugin(),
  89. new CleanWebpackPlugin([
  90. path.resolve(__dirname, './src/**/*.js'),
  91. path.resolve(__dirname, './src/**/*.map')
  92. ]),
  93. new webpack.WatchIgnorePlugin([
  94. /\.js$/,
  95. /\.d\.ts$/
  96. ]),
  97. new MiniCssExtractPlugin({
  98. // Options similar to the same options in webpackOptions.output
  99. // both options are optional
  100. filename: "[name].css",
  101. chunkFilename: "[id].css"
  102. })
  103. ],
  104. watchOptions: {
  105. ignored: [path.resolve(__dirname, './dist/**/*.*'), 'node_modules']
  106. }
  107. }