最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Webpack CommonsChunkPlugin not working as expected - Stack Overflow

programmeradmin1浏览0评论

Folder Structure:

app.js, benchmark.js, board.js all require jquery. I just want to extract jquery as vender.js and three other bundles only contain application code:

Webpack Config:

The result is not what I expected:

app.js, benchmark.js, board.js still contains jquery code (as you can see from the huge file size)

Is there anything wrong with my webpack configuration? I just followed the example in :

Folder Structure:

app.js, benchmark.js, board.js all require jquery. I just want to extract jquery as vender.js and three other bundles only contain application code:

Webpack Config:

The result is not what I expected:

app.js, benchmark.js, board.js still contains jquery code (as you can see from the huge file size)

Is there anything wrong with my webpack configuration? I just followed the example in : https://github./webpack/webpack/tree/master/examples/two-explicit-vendor-chunks https://github./webpack/webpack/tree/master/examples/multiple-entry-points

Share Improve this question asked Sep 27, 2015 at 21:40 AlanAlan 6446 silver badges19 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

plugins should be an object array outside of modules.

Also, I don't think you need the minChunks or chunks options for this use case scenario. Your vendor entry chunk should be sufficient.

entry: {
    vendor: ['jquery']
},
plugins: [
    new webpack.optimize.CommonsChunkPlugin({
        name: "vendor",
        filename:"vendor.js",
        minChunks: Infinity
    })
];
发布评论

评论列表(0)

  1. 暂无评论