Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An unhandled exception occurred: Configuration 'es5' is not set in the workspace. ng serve in angular 8 for es5

An unhandled exception occurred: Configuration 'es5' is not set in the workspace.

The problem starts when clients want the project to run on internet explorer 8. Luckily the new angular 8 offers differential loading.

Based on the documentation(https://angular.io/guide/deployment#differential-loading) by angular I added the es5 JSON to angular.json Then I try to serve it using '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"
}

The error is

An unhandled exception occurred: Configuration 'es5' is not set in the workspace. See "/tmp/ng-iPbP2O/angular-errors.log" for further details.

How can i make this work?

like image 657
abrsh Avatar asked Aug 30 '19 07:08

abrsh


1 Answers

You seem to have put the es5 configuration under the "serve" section, rather than the "configurations" section.

Also you need to change "app:build:es5" to the name of your app. So in your case "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"
      }
    }
  }
like image 67
Riccardo Avatar answered Sep 25 '22 07:09

Riccardo