I'd like to split my vendor code into two chunks, one that contains all angular libraries, and another that contains everything else.
My angular app has a single entry point and is setup something like:
entry: {
app: './path_to/app.js',
vendor: ['jquery', 'moment', 'numeral'],
'vendor.angular': ['angular', 'angular-route', 'angular-numeraljs']
}
I then use the CommonsChunkPlugin to configure the two other bundles:
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
chunks: ['app'],
warnings: false,
filename: 'vendor.bundle.js'
})
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor.angular',
chunks: ['app'],
warnings: false,
filename: 'vendor.angular.bundle.js'
})
This generates 3 files:
Version: webpack 1.13.1
Time: 12719ms
Asset Size Chunks Chunk Names
app.bundle.js 19.2 kB 0 [emitted] app
vendor.bundle.js 484 kB 1 [emitted] vendor
vendor.angular.bundle.js 652 kB 2 [emitted] vendor.angular
[0] multi vendor.angular 124 bytes {2} [built]
[0] multi vendor 88 bytes {1} [built]
+ 124 hidden modules
app.bundle.js contains just my app code.
vendor.bundle.js contains all 3rd party libs excluding angular stuff
vendor.angular.bundle.js contains all angular stuff AND all my 3rd party libs that are already inside of vendor.bundle.js.
Is there anyway to have JUST the angular modules bundled in vendor.angular.bundle.js, without automatically including the other 3rd party libs?
angular_stuff
instead ofvendor.angular
? ... It's just a hunch, but maybe the dot-notation is causing webpack to include the vendor stuff. – HandsCommonsChunkPlugin
minChunks: Infinity
which purpose is to:with more entries, this ensures that no other module goes into the vendor chunk
... so maybe that's the missing option. – HandsCommonsChunkPlugin
-blocks... does it change the file sizes?... maybe because the first optimized common chunk has the 'app'-chunk, then the second one auto-includes the first one. – Handsoutput: {path: path.join(__dirname, "dist"), filename: "[name].bundle.js"}
And then optimze them afterwards? – Handswebpack.optimize.UglifyJsPlugin
.... sorry for the multiple trial and error :-).... ok, I'll be away for a while. Good luck in the meanwhile. – Hands