Angularjs 网页包供应商区块自动创建
我想创建两个网页块:app.js和vendor.js 目前我有smth,如:Angularjs 网页包供应商区块自动创建,angularjs,webpack,Angularjs,Webpack,我想创建两个网页块:app.js和vendor.js 目前我有smth,如: entry = { psw: DIR.src, vendor: ["angular", "angular-ui-router", "angular-bootstrap"] }; ... plugins.push(new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js')) (如这里) 这工作很好(至
entry = {
psw: DIR.src,
vendor: ["angular", "angular-ui-router", "angular-bootstrap"]
};
...
plugins.push(new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js'))
(如这里)
这工作很好(至少它工作正常,看起来还不错)。但是,我希望自动生成“供应商”数组。你知道怎么做吗?使用SplitByPath插件得到了它。它将js和css分开,所以使用起来非常好。不知道为什么它被引用得如此罕见
config.plugins.push(new SplitByPathPlugin([{ name : 'vendor', path: [path.join(__dirname, 'node_modules'), path.join(__dirname, 'bower_components')]}]));
使用SplitByPath插件获得它。它将js和css分开,所以使用起来非常好。不知道为什么它被引用得如此罕见
config.plugins.push(new SplitByPathPlugin([{ name : 'vendor', path: [path.join(__dirname, 'node_modules'), path.join(__dirname, 'bower_components')]}]));