B
B
bernex2017-01-06 12:21:33
webpack
bernex, 2017-01-06 12:21:33

How does CommonsChunkPlugin work in Webpack?

For example, I have a build (610kb) I want to split it into pieces of 200kb.

entry  : {
            app: './client/client.js',
            vendor: [ 'react', 'react-dom', 'react-router', 'react-addons-css-transition-group' ],
            vendor2: [ 'redux', 'react-redux', 'react-dnd', 'react-dnd-html5-backend' ],
            vendor3: ['react-modal', 'reduce-reducers', 'redux-actions']
        },

Dimensions are obtained: 276, 60, 89, 189
If you do:
entry  : {
            app: './client/client.js',
            vendor: [ 'react', 'react-dom', 'react-router', 'react-addons-css-transition-group' ],
        },

They will be: 408 and 204
Question: in the latter case, the correct size and I expect that it will be preserved - but no, when adding other libraries, it is reduced and I do not understand why.
Webpack 2
And plugin config is simple
new webpack.optimize.CommonsChunkPlugin({
                names: ['vendor', 'vendor2', 'vendor3'],
            }),

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question