@nrwl/angular:webpack-browser
The webpack-browser executor is very similar to the standard browser builder provided by the Angular Devkit. It allows you to build your Angular application to a build artifact that can be hosted online. There are some key differences:
- Supports Custom Webpack Configurations
- Supports Incremental Building
Options can be configured in project.json
when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/reference/project-configuration#targets.
Using a custom webpack configuration
The executor supports providing a path to a custom webpack configuration. This allows you to customize how your Angular application is built. It currently supports the following types of webpack configurations:
object
Function
Promise<object|Function>
The executor will merge the provided configuration with the webpack configuration that Angular Devkit uses. The merge order is:
- Angular Devkit Configuration
- Provided Configuration
To use a custom webpack configuration when building your Angular application, change the build
target in your project.json
to match the following:
"build": {
"executor": "@nrwl/angular:webpack-browser",
"options": {
...
"customWebpackConfig": {
"path": "apps/appName/webpack.config.js"
}
}
}
Incrementally Building your Application
The executor supports incrementally building your Angular application by building the workspace libraries it depends on (that have been marked as buildable) and then building your application using the built source of the libraries.
This can improve build time as the building of the workspace libraries can be cached, meaning they only have to be rebuilt if they have changed.
Note: There may be some additional overhead in the linking of the built libraries' sources which may reduce the overall improvement in build time. Therefore this approach only benefits large applications and would likely have a negative impact on small and medium applications.
You can read more about when to use incremental builds here.
To allow your Angular application to take advantage of incremental building, change the build
target in your project.json
to match the following:
"build": {
"executor": "@nrwl/angular:webpack-browser",
"options": {
...
"buildLibsFromSource": false
}
}