Resolve
Js block first extracts the common program is arranged for multi-inlet
Configuration is as follows:
js custom code block
name: Specifies the name of the file pack out
chunks: Look
minSize: 1 package file size
minChunks: indicates how many times the module is referenced to the common module
priority: 1 indicating priority when there are a plurality of common modules when
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name][hash:3].bundle.js',
//将公共 js单独提取到该输出文件 其他模块将不再包含这里面的内容
chunkFilename: '[name][hash:3].js'
},
optimization: {
splitChunks: {
cacheGroups: {
common: {
chunks: 'all',
minSize: 1,
// minChunks: 2,
name: 'common',
priority: 2,
test: /\.js$/
}
}
},
},
For when referring to third-party software libraries
Configuration is as follows
Regular test pack which indicates a third-party library
Difference between the two:
C shows the first file tree-shaking referenced B in terms of B file for a particular document references a file A is a longitudinal reference js
As scope chain itself as webpack js-tree-shaing does not have scope filtering. FIG. A method of file references a
Shaking does not have the function mode npm run dev
Under npm run prod a packing mode a, c, d method does not have the functionality to be removed scope filters c, d depth tree-shaking
Depth tree-shaking not only relates to a package outside the scope of the code