Add splitChunks plugin and its configs

Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com>
This commit is contained in:
Hung-Han (Henry) Chen committed 2021-01-07 11:22:49 +08:00
1 parent 8dfe991adc
commit bcfa00aea5
2 files changed
+18

No files matched your search

+9
View File
@@ -36,6 +36,15 @@ export default function (): webpack.Configuration {
externals: nodeExternals(), externals: nodeExternals(),
optimization: { optimization: {
minimize: isProduction, 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: { module: {
rules: [ rules: [
+9
View File
@@ -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: { module: {