发生未处理的异常:工作区中未设置配置 'es5'。 ng 在 angular 8 中为 es5 服务
An unhandled exception occurred: Configuration 'es5' is not set in the workspace. ng serve in angular 8 for es5
发生未处理的异常:工作区中未设置配置 'es5'。
当客户希望项目在 Internet Explorer 8 上 运行 时,问题就出现了。幸运的是,新的 angular 8 提供了差异加载。
根据 angular 的文档 (https://angular.io/guide/deployment#differential-loading),我将 es5 JSON 添加到 angular.json
然后我尝试使用 'ng serve --configuration es5'
来提供它
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"sm": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"style": "sass"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/Forex-Lottery-Front-End",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/font-awesome/scss/font-awesome.scss",
"./node_modules/bootstrap/dist/css/bootstrap.css",
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/scss/styles.scss"
],
"scripts": [
"./node_modules/jquery/dist/jquery.js"
],
"es5BrowserSupport": true
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"es5": {
"tsConfig": "./tsconfig-es5.app.json"
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "sm:build"
},
"configurations": {
"production": {
"browserTarget": "sm:build:production"
}
},
"es5": {
"browserTarget": "app:build:es5"
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "sm:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.scss"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"sm-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "sm:serve"
},
"configurations": {
"production": {
"devServerTarget": "sm:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "sm"
}
错误是
发生未处理的异常:工作区中未设置配置 'es5'。
有关详细信息,请参阅“/tmp/ng-iPbP2O/angular-errors.log”。
我怎样才能让它工作?
您似乎将 es5 配置放在了 "serve" 部分,而不是 "configurations" 部分。
您还需要将 "app:build:es5" 更改为您的应用名称。所以在你的情况下 "sm:build:es5".
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "sm:build"
},
"configurations": {
"production": {
"browserTarget": "sm:build:production"
},
"es5": {
"browserTarget": "sm:build:es5"
}
}
}
发生未处理的异常:工作区中未设置配置 'es5'。
当客户希望项目在 Internet Explorer 8 上 运行 时,问题就出现了。幸运的是,新的 angular 8 提供了差异加载。
根据 angular 的文档 (https://angular.io/guide/deployment#differential-loading),我将 es5 JSON 添加到 angular.json 然后我尝试使用 'ng serve --configuration es5'
来提供它{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"sm": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"style": "sass"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/Forex-Lottery-Front-End",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/font-awesome/scss/font-awesome.scss",
"./node_modules/bootstrap/dist/css/bootstrap.css",
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/scss/styles.scss"
],
"scripts": [
"./node_modules/jquery/dist/jquery.js"
],
"es5BrowserSupport": true
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"es5": {
"tsConfig": "./tsconfig-es5.app.json"
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "sm:build"
},
"configurations": {
"production": {
"browserTarget": "sm:build:production"
}
},
"es5": {
"browserTarget": "app:build:es5"
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "sm:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.scss"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"sm-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "sm:serve"
},
"configurations": {
"production": {
"devServerTarget": "sm:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "sm"
}
错误是
发生未处理的异常:工作区中未设置配置 'es5'。 有关详细信息,请参阅“/tmp/ng-iPbP2O/angular-errors.log”。
我怎样才能让它工作?
您似乎将 es5 配置放在了 "serve" 部分,而不是 "configurations" 部分。
您还需要将 "app:build:es5" 更改为您的应用名称。所以在你的情况下 "sm:build:es5".
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "sm:build"
},
"configurations": {
"production": {
"browserTarget": "sm:build:production"
},
"es5": {
"browserTarget": "sm:build:es5"
}
}
}