From bcfa00aea59d6ecf984c3eb0562964e3c91bd8e8 Mon Sep 17 00:00:00 2001 From: "Hung-Han (Henry) Chen" <1474479+chenhunghan@users.noreply.github.com> Date: Mon, 14 Dec 2020 14:24:46 +0800 Subject: [PATCH] Add splitChunks plugin and its configs Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com> --- webpack.main.ts | 9 +++++++++ webpack.renderer.ts | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/webpack.main.ts b/webpack.main.ts index c060778073..cb2311fe15 100755 --- a/webpack.main.ts +++ b/webpack.main.ts @@ -36,6 +36,15 @@ export default function (): webpack.Configuration { externals: nodeExternals(), optimization: { minimize: isProduction, + // Automatically split vendor and commons in development + // (for faster re-compiling) + // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366 + splitChunks: isDevelopment ? { + chunks: "all", + } : false, + runtimeChunk: isDevelopment ? { + name: (entrypoint: { name: string }) => `runtime-${entrypoint.name}`, + } : false, }, module: { rules: [ diff --git a/webpack.renderer.ts b/webpack.renderer.ts index 981a996613..91108a257e 100755 --- a/webpack.renderer.ts +++ b/webpack.renderer.ts @@ -79,6 +79,15 @@ export function webpackLensRenderer({ showVars = true } = {}): webpack.Configura } }) ], + // Automatically split vendor and commons in development + // (for faster re-compiling) + // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366 + splitChunks: isDevelopment ? { + chunks: "all", + }: false, + runtimeChunk: isDevelopment ? { + name: (entrypoint: { name: string }) => `runtime-${entrypoint.name}`, + }: false, }, module: {