How to run e2e test with ngx-build-plus (extra-webpack-config)?

1.5k Views Asked by At

I use ngx-build-plus to include a special webpack loader to integrate special custom files into our Angular-CLI build process (Angular 10).

Everything works fine, however I couldn't find a way to use e2e-tests this way, it's not even taking the --extra-webpack-config option...

$ ng e2e --extra-webpack-config webpack.partial.js
Unknown option: '--extra-webpack-config'
Unknown option: 'webpack.partial.js'

How could I fix the e2e tests to use the webpack.partial.js ?

2

There are 2 best solutions below

1
hoeni On BEST ANSWER

After many things I've tried I couldn't find out how to get it to work with ngx-build-plus at all. However, I found out there is a different module @angular-builders/custom-webpack which provides exact the functionality of seamlessly extending an Angular-CLI webpack configuration and worked perfectly with my e2e-tests. There is no need to pass arguments to the build process, as the name of the webpack.conf fragment s configured in the angular.json config file:

"customWebpackConfig": {
    "path": "./webpack.config.js"
}
1
Nathan On

Might be a little late here, but you need to change your builder in the angular.json file

Replace:

"builder": "angular-cli-builders:custom-webpack-browser"

With

"builder": "ngx-build-plus:browser"

This was not mentioned in the documentation so i had to do some digging in their sample projects. Works like a charm

Successful Build