要求是为每种语言创建应用程序包,并分割供应商模块。以下webpack.config.js
// webpack.config.js
var webpack = require('webpack')
var path = require('path')
var I18nPlugin = require("i18n-webpack-plugin")
var locales = {
"en": require("./m1/js/en.json"),
"ja": require("./m1/js/ja.json")
}
module.exports = Object.keys(locales).map(function (locale) {
return {
name: locale,
entry: "./m1/js/main.js",
output: {
filename: 'app-' + locale + '.js',
path: path.resolve(__dirname, 'm1/js/build')
},
plugins: [
new I18nPlugin(
locales[locale],
{
functionName: '_t',
}
),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module) {
return module.context && module.context.indexOf('node_modules') !== -1;
}
})
]
}
})
抛出以下错误:
ERROR in chunk vendor [entry]
app-en.js
Conflict: Multiple assets emit to the same filename app-en.js
ERROR in chunk vendor [entry]
app-ja.js
Conflict: Multiple assets emit to the same filename app-ja.js
有人可以帮我这个吗?
答案 0 :(得分:0)
好吧,我改变了我的web.config.js,如下所示:
...
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.js',
minChunks: function (module) {
return module.context && module.context.indexOf('node_modules') !== -1;
}
})
...
它有效。我只是不确定它是否有效或正确。我关心的是地图功能。是否为每个区域设置写入vendor.js?