webpack.config.js 3.0 KB

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