webpack.config.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. const DtsBundleWebpack = require('dts-bundle-webpack')
  4. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  5. const CleanWebpackPlugin = require('clean-webpack-plugin');
  6. module.exports = {
  7. context: __dirname,
  8. entry: {
  9. 'babylonjs-inspector': path.resolve(__dirname, './src/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'],
  24. alias: {
  25. Split: path.resolve(__dirname, '../dist/preview release/split.js')
  26. }
  27. },
  28. externals: {
  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-gltf2interface": {
  42. root: "BABYLON",
  43. commonjs: "babylonjs-gltf2interface",
  44. commonjs2: "babylonjs-gltf2interface",
  45. amd: "babylonjs-gltf2interface"
  46. },
  47. "babylonjs-loaders": {
  48. root: "BABYLON",
  49. commonjs: "babylonjs-loaders",
  50. commonjs2: "babylonjs-loaders",
  51. amd: "babylonjs-loaders"
  52. },
  53. "babylonjs-serializers": {
  54. root: "BABYLON",
  55. commonjs: "babylonjs-serializers",
  56. commonjs2: "babylonjs-serializers",
  57. amd: "babylonjs-serializers"
  58. }
  59. },
  60. devtool: "source-map",
  61. module: {
  62. rules: [{
  63. test: /\.tsx?$/,
  64. loader: "ts-loader",
  65. exclude: /node_modules/
  66. },
  67. {
  68. test: /\.scss$/,
  69. use: [
  70. // fallback to style-loader in development
  71. process.env.NODE_ENV !== 'production' ? 'style-loader' : MiniCssExtractPlugin.loader,
  72. "css-loader",
  73. "sass-loader"
  74. ]
  75. }]
  76. },
  77. mode: "production",
  78. devServer: {
  79. contentBase: path.join(__dirname, "dist"),
  80. compress: false,
  81. //open: true,
  82. port: 9000
  83. },
  84. plugins: [
  85. new CleanWebpackPlugin([
  86. path.resolve(__dirname, './src/**/*.js'),
  87. path.resolve(__dirname, './src/**/*.map')
  88. ]),
  89. // removed due to the way gulp=webpack works
  90. /*new DtsBundleWebpack({
  91. name: "babylonjs-inspector",
  92. main: path.resolve(__dirname, '../dist/preview release/inspector/build/index.d.ts'),
  93. out: path.resolve(__dirname, '../dist/preview release/inspector/babylon.inspector.module.d.ts'),
  94. baseDir: path.resolve(__dirname, '../dist/preview release/inspector/build/'),
  95. headerText: "BabylonJS Inspector"
  96. }),*/
  97. new webpack.WatchIgnorePlugin([
  98. /\.js$/,
  99. /\.d\.ts$/
  100. ]),
  101. new MiniCssExtractPlugin({
  102. // Options similar to the same options in webpackOptions.output
  103. // both options are optional
  104. filename: "[name].css",
  105. chunkFilename: "[id].css"
  106. })
  107. ],
  108. watchOptions: {
  109. ignored: [path.resolve(__dirname, './dist/**/*.*'), 'node_modules']
  110. }
  111. }