Skip to content

Commit c1046e9

Browse files
committed
feat: add chunk splitting
1 parent d4c2daa commit c1046e9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/index.cjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const path = require('path');
33
const merge = require('lodash.merge');
44
const nodeExternals = require('webpack-node-externals');
55

6+
const DEFAULT_CHUNK_FILENAME = 'chunks/[name].[chunkhash].js';
7+
68
/**
79
* @typedef {import('webpack').Configuration} Configuration
810
* @typedef {import('webpack').RuleSetRule} RuleSetRule
@@ -51,11 +53,17 @@ class ScratchWebpackConfigBuilder {
5153
[libraryName]: path.resolve(this._srcPath, 'index')
5254
} : path.resolve(this._srcPath, 'index'),
5355
optimization: {
54-
minimize: isProduction
56+
minimize: isProduction,
57+
splitChunks: {
58+
chunks: 'all',
59+
filename: DEFAULT_CHUNK_FILENAME
60+
},
61+
mergeDuplicateChunks: true
5562
},
5663
output: {
5764
clean: true,
5865
filename: '[name].js',
66+
chunkFilename: DEFAULT_CHUNK_FILENAME,
5967
path: this._distPath,
6068
library: {
6169
name: libraryName,

0 commit comments

Comments
 (0)