Просмотр исходного кода

fix: Move chunk splitting from prod to common so we get the same files in dev as prod

Johannes Schill 6 лет назад
Родитель
Сommit
e3ddfccb61
3 измененных файлов с 13 добавлено и 31 удалено
  1. 13 1
      scripts/webpack/webpack.common.js
  2. 0 19
      scripts/webpack/webpack.dev.js
  3. 0 11
      scripts/webpack/webpack.prod.js

+ 13 - 1
scripts/webpack/webpack.common.js

@@ -10,7 +10,7 @@ module.exports = {
     path: path.resolve(__dirname, '../../public/build'),
     path: path.resolve(__dirname, '../../public/build'),
     filename: '[name].[hash].js',
     filename: '[name].[hash].js',
     // Keep publicPath relative for host.com/grafana/ deployments
     // Keep publicPath relative for host.com/grafana/ deployments
-    publicPath: "public/build/",
+    publicPath: 'public/build/',
   },
   },
   resolve: {
   resolve: {
     extensions: ['.ts', '.tsx', '.es6', '.js', '.json', '.svg'],
     extensions: ['.ts', '.tsx', '.es6', '.js', '.json', '.svg'],
@@ -61,6 +61,18 @@ module.exports = {
       }
       }
     ]
     ]
   },
   },
+  // https://webpack.js.org/plugins/split-chunks-plugin/#split-chunks-example-3
+  optimization: {
+    splitChunks: {
+      cacheGroups: {
+        commons: {
+          test: /[\\/]node_modules[\\/].*[jt]sx?$/,
+          name: 'vendor',
+          chunks: 'all'
+        }
+      }
+    }
+  },
   plugins: [
   plugins: [
     new ForkTsCheckerWebpackPlugin({
     new ForkTsCheckerWebpackPlugin({
       checkSyntacticErrors: true,
       checkSyntacticErrors: true,

+ 0 - 19
scripts/webpack/webpack.dev.js

@@ -58,25 +58,6 @@ module.exports = merge(common, {
     ]
     ]
   },
   },
 
 
-  optimization: {
-    splitChunks: {
-      cacheGroups: {
-        manifest: {
-          chunks: "initial",
-          test: "vendor",
-          name: "vendor",
-          enforce: true
-        },
-        vendor: {
-          chunks: "initial",
-          test: "vendor",
-          name: "vendor",
-          enforce: true
-        }
-      }
-    }
-  },
-
   plugins: [
   plugins: [
     new CleanWebpackPlugin('../../public/build', { allowExternal: true }),
     new CleanWebpackPlugin('../../public/build', { allowExternal: true }),
     new MiniCssExtractPlugin({
     new MiniCssExtractPlugin({

+ 0 - 11
scripts/webpack/webpack.prod.js

@@ -47,17 +47,7 @@ module.exports = merge(common, {
       })
       })
     ]
     ]
   },
   },
-
   optimization: {
   optimization: {
-    splitChunks: {
-      cacheGroups: {
-        commons: {
-          test: /[\\/]node_modules[\\/].*[jt]sx?$/,
-          name: "vendor",
-          chunks: "all"
-        }
-      }
-    },
     minimizer: [
     minimizer: [
       new UglifyJsPlugin({
       new UglifyJsPlugin({
         cache: true,
         cache: true,
@@ -67,7 +57,6 @@ module.exports = merge(common, {
       new OptimizeCSSAssetsPlugin({})
       new OptimizeCSSAssetsPlugin({})
     ]
     ]
   },
   },
-
   plugins: [
   plugins: [
     new MiniCssExtractPlugin({
     new MiniCssExtractPlugin({
       filename: "grafana.[name].[hash].css"
       filename: "grafana.[name].[hash].css"