With Angular CLI 6 you need to use builders as ng eject is deprecated and will soon be removed in 8.0. That’s what it says when I try to do an ng eject
You can use angular-builders package (https://github.com/meltedspark/angular-builders) to provide your custom webpack config.
I have tried to summarize all in a single blog post on my blog – How to customize build configuration with custom webpack config in Angular CLI 6
but essentially you add following dependencies –
"devDependencies": { "@angular-builders/custom-webpack": "^7.0.0", "@angular-builders/dev-server": "^7.0.0", "@angular-devkit/build-angular": "~0.11.0",
In angular.json make following changes –
"architect": { "build": { "builder": "@angular-builders/custom-webpack:browser", "options": { "customWebpackConfig": {"path": "./custom-webpack.config.js"},
Notice change in builder and new option customWebpackConfig. Also change
"serve": { "builder": "@angular-builders/dev-server:generic",
Notice the change in builder again for serve target. Post these changes you can create a file called custom-webpack.config.js in your same root directory and add your webpack config there.
However, unlike ng eject configuration provided here will be merged with default config so just add stuff you want to edit/add.