webpack.config.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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, './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. test: /\.css$/,
  73. use: ['style-loader', 'css-loader']
  74. }]
  75. },
  76. mode: "production",
  77. devServer: {
  78. contentBase: path.join(__dirname, "dist"),
  79. compress: false,
  80. //open: true,
  81. port: 9000
  82. },
  83. performance: {
  84. hints: false
  85. },
  86. plugins: [
  87. new HardSourceWebpackPlugin(),
  88. new webpack.WatchIgnorePlugin([
  89. /\.js$/,
  90. /\.d\.ts$/
  91. ]),
  92. new MiniCssExtractPlugin({
  93. // Options similar to the same options in webpackOptions.output
  94. // both options are optional
  95. filename: "[name].css",
  96. chunkFilename: "[id].css"
  97. })
  98. ],
  99. watchOptions: {
  100. ignored: [path.resolve(__dirname, './dist/**/*.*'), 'node_modules']
  101. }
  102. }