简体   繁体   中英

Webpack CommonsChunkPlugin not working as expected

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)

Webpack输出

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

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
    })
];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM