Angular-builders: "customWebpackConfig" option not supported by Angular 8?

Created on 5 Jun 2019  路  2Comments  路  Source: just-jeb/angular-builders

I get the following error when building an Angular 8 project:

$ ng build common-components --prod --output-hashing=none

Schema validation failed with the following errors:
   Data path "" should NOT have additional properties(customWebpackConfig).

It seems the "customWebpackConfig" option is no longer supported by the angular.json schema in Angular 8.

Versions

  • "@angular-builders/custom-webpack": "^8.0.2"
  • "@angular-devkit/build-angular": "~0.800.0"
  • "@angular/cli": "~8.0.1"
  • npm 6.5.0

Project configuration
It is an Angular workspace (web-components) containing two projects: common-components and maps-components:

package.json
```{
"name": "web-components",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --aot",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build-common": "ng build common-components --prod --output-hashing=none",
"build-maps": "ng build maps-components --prod --output-hashing=none",
"build": "npm run build-common && npm run build-maps",
"package-common": "jscat ./dist/common-components/runtime.js ./dist/common-components/polyfills.js ./dist/common-components/scripts.js ./dist/common-components/main.js > ./dist/common-components.js",
"package-maps": "jscat ./dist/maps-components/runtime.js ./dist/common-components/polyfills.js ./dist/maps-components/scripts.js ./dist/maps-components/main.js > ./dist/maps-components.js",
"package": "npm run package-common && npm run package-maps"
},
"private": true,
"dependencies": {
"@angular/animations": "~8.0.0",
"@angular/common": "~8.0.0",
"@angular/compiler": "~8.0.0",
"@angular/core": "~8.0.0",
"@angular/elements": "^8.0.0",
"@angular/forms": "~8.0.0",
"@angular/platform-browser": "~8.0.0",
"@angular/platform-browser-dynamic": "~8.0.0",
"@angular/router": "~8.0.0",
"rxjs": "~6.4.0",
"tslib": "^1.9.0",
"zone.js": "~0.9.1",
"document-register-element": "^1.7.2"
},
"devDependencies": {
"@angular-builders/custom-webpack": "^8.0.2",
"@angular-devkit/build-angular": "~0.800.0",
"@angular/cli": "~8.0.1",
"@angular/compiler-cli": "~8.0.0",
"@angular/language-service": "~8.0.0",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.4.3"
}
}

**`angular.json`**
```{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "maps-components": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        }
      },
      "root": "projects/maps-components",
      "sourceRoot": "projects/maps-components/src",
      "prefix": "acme",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",          
          "options": {
            "outputPath": "dist/maps-components",
            "index": "projects/maps-components/src/index.html",
            "main": "projects/maps-components/src/main.ts",
            "polyfills": "projects/maps-components/src/polyfills.ts",
            "tsConfig": "projects/maps-components/tsconfig.app.json",
            "assets": [
              "projects/maps-components/src/favicon.ico",
              "projects/maps-components/src/assets"
            ],
            "styles": [
              "projects/maps-components/src/styles.scss"
            ],
            "scripts": [
              {
                "input": "node_modules/document-register-element/build/document-register-element.js"
              }
            ],            
            "customWebpackConfig": { 
                "path": "projects/maps-components/extra-webpack.config.js",
                "mergeStrategies": { "externals": "replace" } 
            }
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "projects/maps-components/src/environments/environment.ts",
                  "with": "projects/maps-components/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"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "maps-components:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "maps-components:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "maps-components:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "projects/maps-components/src/test.ts",
            "polyfills": "projects/maps-components/src/polyfills.ts",
            "tsConfig": "projects/maps-components/tsconfig.spec.json",
            "karmaConfig": "projects/maps-components/karma.conf.js",
            "assets": [
              "projects/maps-components/src/favicon.ico",
              "projects/maps-components/src/assets"
            ],
            "styles": [
              "projects/maps-components/src/styles.scss"
            ],
            "scripts": []
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "projects/maps-components/tsconfig.app.json",
              "projects/maps-components/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "common-components": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        }
      },
      "root": "projects/common-components",
      "sourceRoot": "projects/common-components/src",
      "prefix": "acme",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/common-components",
            "index": "projects/common-components/src/index.html",
            "main": "projects/common-components/src/main.ts",
            "polyfills": "projects/common-components/src/polyfills.ts",
            "tsConfig": "projects/common-components/tsconfig.app.json",
            "assets": [
              "projects/common-components/src/favicon.ico",
              "projects/common-components/src/assets"
            ],
            "styles": [
              "projects/common-components/src/styles.scss"
            ],
            "scripts": [
              {
                "input": "node_modules/document-register-element/build/document-register-element.js"
              }
            ],
            "customWebpackConfig": { 
                "path": "projects/common-components/extra-webpack.config.js",
                "mergeStrategies": { "externals": "replace" } 
            }
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "projects/common-components/src/environments/environment.ts",
                  "with": "projects/common-components/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"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "common-components:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "common-components:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "common-components:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "projects/common-components/src/test.ts",
            "polyfills": "projects/common-components/src/polyfills.ts",
            "tsConfig": "projects/common-components/tsconfig.spec.json",
            "karmaConfig": "projects/common-components/karma.conf.js",
            "assets": [
              "projects/common-components/src/favicon.ico",
              "projects/common-components/src/assets"
            ],
            "styles": [
              "projects/common-components/src/styles.scss"
            ],
            "scripts": []
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "projects/common-components/tsconfig.app.json",
              "projects/common-components/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "maps-components"
}

web-components/projects/common-components/extra-webpack.config.js
```module.exports = {
output: {
jsonpFunction: 'webpackJsonpCommonComponents',
library: 'commoncomponents'
}
};

**`web-components/projects/maps-components/extra-webpack.config.js`**
```module.exports = {
  output: {
  jsonpFunction: 'webpackJsonpMapsComponents',
  library: 'mapscomponents'
  }
};

Most helpful comment

I see that you're not actually _using_ the builder. You should replace @angular-devkit/build-angular:[builder] with @angular-builders/custom-webpack:[builder] in _angular.json_.

All 2 comments

I see that you're not actually _using_ the builder. You should replace @angular-devkit/build-angular:[builder] with @angular-builders/custom-webpack:[builder] in _angular.json_.

...OMG!

It works.

Thank you!

Was this page helpful?
0 / 5 - 0 ratings