var webpack=require (' webpack ' Span style= "COLOR: #0000ff" >var path=require (' path ' =< Span style= "COLOR: #000000" >{entry:{ ' pagea ': './src/pagea ' ' vendor ': [' Lodash ' ]},output:{path: Path.resolve (__dirname, './dist ' ' [name].bundle.js ' "[name].chunk.js" },plugins:[ Span style= "COLOR: #0000ff" >new Webpack.optimize.CommonsChunkPlugin ({name: ' Vendor ' //
]}
This is added vender, not coupled with PageA, and PageB, then introduced Subpagea, and Subpageb,nodule. And then you build a common.bundle.js inside.
The code repeats the block, extracting the code that repeats quickly. Subpagea, and Subpageb,noduleminchunks:2 is the extraction of the configured duplicate code. Add a plugin later, but the code is mixed together after packaging
New Webpack.optimize.CommonsChunkPlugin ({ name:' manifest ', // This is to distinguish between the code of the Webpack and the code of the plugin })
Here is the separation of Webpcak code and plug-in code.
Webpack code Segmentation;