webpack.config.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. },
  24. externals: [
  25. {
  26. babylonjs: {
  27. root: "BABYLON",
  28. commonjs: "babylonjs",
  29. commonjs2: "babylonjs",
  30. amd: "babylonjs"
  31. },
  32. "babylonjs-gui": {
  33. root: ["BABYLON", "GUI"],
  34. commonjs: "babylonjs-gui",
  35. commonjs2: "babylonjs-gui",
  36. amd: "babylonjs-gui"
  37. },
  38. "babylonjs-loaders": {
  39. root: "BABYLON",
  40. commonjs: "babylonjs-loaders",
  41. commonjs2: "babylonjs-loaders",
  42. amd: "babylonjs-loaders"
  43. },
  44. "babylonjs-serializers": {
  45. root: "BABYLON",
  46. commonjs: "babylonjs-serializers",
  47. commonjs2: "babylonjs-serializers",
  48. amd: "babylonjs-serializers"
  49. }
  50. },
  51. /^babylonjs.*$/i
  52. ],
  53. devtool: "source-map",
  54. module: {
  55. rules: [{
  56. test: /\.tsx?$/,
  57. loader: 'awesome-typescript-loader',
  58. options: {
  59. configFileName: '../../inspector/tsconfig.json',
  60. declaration: false
  61. }
  62. },
  63. {
  64. test: /\.scss$/,
  65. use: [
  66. // fallback to style-loader in development
  67. process.env.NODE_ENV !== 'production' ? 'style-loader' : MiniCssExtractPlugin.loader,
  68. "css-loader",
  69. "sass-loader"
  70. ]
  71. },
  72. {
  73. test: /\.css$/,
  74. use: ['style-loader', 'css-loader']
  75. }]
  76. },
  77. mode: "production",
  78. performance: {
  79. hints: false
  80. },
  81. plugins: [
  82. new HardSourceWebpackPlugin(),
  83. new webpack.WatchIgnorePlugin([
  84. /\.js$/,
  85. /\.d\.ts$/
  86. ]),
  87. new MiniCssExtractPlugin({
  88. // Options similar to the same options in webpackOptions.output
  89. // both options are optional
  90. filename: "[name].css",
  91. chunkFilename: "[id].css"
  92. })
  93. ]
  94. }