你好,我在 Angular 8 中创建了一个项目。一开始只支持默认语言(美式英语)。然后我加入了本地化。
在本地化之前,我用以下命令来准备生产构建。
ng build --prod --base-href "/Windchill/com/qiwkCollaborator/"
在本地化后,我对angular.json和package.json进行了一些更改。在做出这些更改之后,无论我给出什么命令来准备构建,它都会给我以下错误。
An unhandled exception occurred: Configuration 'production' is not set in the workspace.
Package.json文件的一部分如下:
"name": "qwik-collaborator",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build-locale:en": "ng build --prod --i18n-locale en --i18n-format xlf --i18n-file src/translate/messages.en.xlf --output-path=dist/en --baseHref /en/",
"build-locale:fr": "ng build --prod --i18n-locale fr --i18n-format xlf --i18n-file src/translate/messages.fr.xlf --output-path=dist/fr --baseHref /fr/"
Angular.json文件的一部分内容如下。
"build": {
"configurations": {
"fr": {
"aot": true,
"outputPath": "dist/qwikCollaborator/fr/",
"i18nFile": "src/translate/messages.fr.xlf",
"i18nFormat": "xlf",
"i18nLocale": "fr",
"i18nMissingTranslation": "error"
},
"en": {
"aot": true,
"outputPath": "dist/qwikCollaborator/en/",
"i18nFile": "src/translate/messages.en.xlf",
"i18nFormat": "xlf",
"i18nLocale": "en",
"i18nMissingTranslation": "error"
}
},
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/qwikCollaborator",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": false,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss",
"src/assets/css/custom-mobile.css",
"src/assets/css/custom.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"src/assets/js/qwikCollaborator.js"
]
},
"configurations": {
"es5": {
"tsConfig": "./tsconfig.es5.json"
},
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
.......
"serve": {
"configurations": {
"fr": {
"browserTarget": "qwikCollaborator:build:fr"
},
"en": {
"browserTarget": "qwikCollaborator:build:en"
} ,
},
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "qwikCollaborator:build"
},
"configurations": {
"es5": {
"browserTarget": "qwikCollaborator:build:es5"
},
"production": {
"browserTarget": "qwikCollaborator:build:es5"
}
}
},
有谁能帮我解决这个问题吗?