Home  >  Q&A  >  body text

javascript - 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)
})
PHP中文网PHP中文网2749 days ago427

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-04-10 16:00:50

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

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

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-10 16:00:50

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

    reply
    0
  • Cancelreply