[英]Pass custom environment parameters to @angular-builders/custom-webpack
in our Angular 9 application we have multiple environments configured in angular.json.在我们的 Angular 9 应用程序中,我们在 angular.json 中配置了多个环境。
We also use @angular-builders/custom-webpack to add some custom plugins that need some input variables based on environment but if I add a custom property to the environment node i get this error:我们还使用 @angular-builders/custom-webpack 添加一些自定义插件,这些插件需要一些基于环境的输入变量,但是如果我向环境节点添加自定义属性,我会收到此错误:
Data path "" should NOT have additional properties(customPluginConfigForSandboxEnvironment)
数据路径“”不应具有其他属性(customPluginConfigForSandboxEnvironment)
"architect": {
"build": {
"configurations": {
"sandbox": {
"outputPath": ....,
"customPluginConfigForSandboxEnvironment": {}
Is it possible to do something like this?有可能做这样的事情吗?
In the customWebpackConfig file I can read the outputPath from options在 customWebpackConfig 文件中,我可以从选项中读取 outputPath
module.exports = (config, options) => {
and here save my extra configuration, but I prefer to keep all the configurations into the angular.json if it's possible.并在这里保存我的额外配置,但如果可能的话,我更愿意将所有配置保留在 angular.json 中。
Thanks谢谢
You can use two separate configuration files:您可以使用两个单独的配置文件:
{
...
"projects": {
"your-app": {
...
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"mergeRules": {
"externals": "replace"
}
},
...
},
"configurations": {
"production": {
"customWebpackConfig": {
"path": "./webpack.config.prod.ts"
},
...
},
"development": {
"customWebpackConfig": {
"path": "./webpack.config.dev.ts"
}
}
},
...
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.