首页 > webpack CommonsChunkPlugin插件配置问题

webpack CommonsChunkPlugin插件配置问题

http://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin

里的 name 和 filename有什么区别 ?

new CommonsChunkPlugin({
  name: "commons",
  // (the commons chunk name)

  filename: "commons.js",
  // (the filename of the commons chunk)

  // minChunks: 3,
  // (Modules must be shared between 3 entries)

  // chunks: ["pageA", "pageB"],
  // (Only use these entries)
})

name 是 chunk 的名字,可以用来做入口文件,而
filename 是最终js的路径。


name 是配置文件里面入口文件的键名,filename 是输出的文件名。

var  webpack = require('webpack')
 module.exports = {
    entry : {
        vendor : ['jquery']
    }
    ...
    plugins : [
        new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js')
    ]
 }
【热门文章】
【热门文章】