[vue]vue.config.js: “plugins“ is not allowed
vue.config.js: “plugins” is not allowedproblemvue-cli 创建vue工程,生成 vue.config.js需要再 vue.config.js 中使用 ModuleFederationPlugin按照 webpack 官方配置 此plugin后 重启服务报错$ vue-cli-service serveERRORInvalid options in
·
vue.config.js: “plugins” is not allowed
problem
- vue-cli 创建vue工程,生成 vue.config.js
- 需要再 vue.config.js 中使用 ModuleFederationPlugin
- 按照 webpack 官方配置 此plugin后 重启服务
- 报错信息如下
$ vue-cli-service serve
ERROR Invalid options in vue.config.js: "plugins" is not allowed
error Command failed with exit code 1.
reason
vue.config.js 不等于 webpack 配置
solution
在 plugins 外包裹一层 configureWebpack
module.exports = {
configureWebpack: {
plugins: [
new ModuleFederationPlugin({
name: "app2",
remotes: {
app1: "app1@http://localhost:8080/remoteEntry.js",
}
})
]
}
}
关于configureWebpack(Type: Object | Function)
- 如果传入参数是:对象,则会通过 webpack-merge 合并到最终的配置中
- 如果传入参数是:函数,则会接收被解析的配置作为参数
更多推荐
已为社区贡献6条内容
所有评论(0)