17.0.2 • Published 10 days ago

@angular-builders/custom-webpack v17.0.2

Weekly downloads
200,780
License
MIT
Repository
github
Last release
10 days ago

custom-webpack npm version

Custom webpack builders for Angular build facade.
Allow customizing build configuration without ejecting webpack configuration (ng eject)

Prerequisites:

Usage

  1. npm i -D @angular-builders/custom-webpack
  2. In your angular.json:
    "projects": {
        ...
        "[project]": {
             ...
             "architect": {
                    ...
                    "[architect-target]": {
                              "builder": "@angular-builders/custom-webpack:[browser|server]"
                              "options": {
                                    ...
                              }
    Where:
  3. If [architect-target] is not one of the predefined targets (like build, serve etc.) then run it like this:
    ng run [project]:[architect-target]
    If it is one of the predefined targets, you can run it by ng [architect-target]

    For example

  • angular.json:
    "projects": {
        ...
        "example-app": {
             ...
             "architect": {
                    ...
                    "build": {
                              "builder": "@angular-builders/custom-webpack:browser"
                              "options": {
                                    ...
                              }
  • Run the build: ng build

Builders

Custom webpack browser

Extended @angular-devkit/build-angular:browser builder that allows to specify additional webpack configuration (on top of the existing under the hood). The builder will run the same build as @angular-devkit/build-angular:browser does with extra parameters that are specified in the provided webpack configuration.

Options:

  • All the @angular-devkit/build-angular:browser options
  • customWebpackConfig: configuration object with the following properties:
    • path: path to the extra webpack configuration, defaults to webpack.config.js
    • mergeStrategies: webpack config merge strategies, can be append | prepend | replace per webpack config entry. Defaults to append.
      • append: appends the given entry configuration (in custom webpack config) to the existing Angular CLI webpack configuration.
      • prepend: prepends the given entry configuration (in custom webpack config) to the existing field configuration (in Angular CLI webpack config). The custom loaders config will be added to the beginning of the existing loaders array.
      • replace: replaces the given entry configuration entirely. The custom webpack config will replace the Angular CLI webpack config (for this particular entry). See webpack-merge for more info.
    • replaceDuplicatePlugins: Defaults to false. If true, the plugins in custom webpack config will replace the corresponding plugins in default Angular CLI webpack configuration.

angular.json Example:

"architect": {
    ...
    "build": {
              "builder": "@angular-builders/custom-webpack:browser"
              "options": {
                     "customWebpackConfig": {
                        path: "./extra-webpack.config.js",
                        mergeStrategies: { "externals": "prepend" },
                     }
                     "outputPath": "dist/my-cool-client",
                     "index": "src/index.html",
                     "main": "src/main.ts",
                     "polyfills": "src/polyfills.ts",
                     "tsConfig": "src/tsconfig.app.json"
              }

In this example externals entry from extra-webpack.config.js will be prepended to externals entry from Angular CLI underlying webpack config.

Custom webpack server

Extended @angular-devkit/build-angular:server builder that allows to specify additional webpack configuration (on top of the existing under the hood). The builder will run the same build as @angular-devkit/build-angular:server does with extra parameters that are specified in the provided webpack configuration.

Options:

  • All the @angular-devkit/build-angular:server options
  • customWebpackConfig: configuration object with the following properties:
    • path: path to the extra webpack configuration, defaults to webpack.config.js
    • mergeStrategies: webpack config merge strategies, can be append | prepend | replace per webpack config entry. Defaults to append.
      • append: appends the given entry configuration (in custom webpack config) to the existing Angular CLI webpack configuration.
      • prepend: prepends the given entry configuration (in custom webpack config) to the existing field configuration (in Angular CLI webpack config). The custom loaders config will be added to the beginning of the existing loaders array.
      • replace: replaces the given entry configuration entirely. The custom webpack config will replace the Angular CLI webpack config (for this particular entry). See webpack-merge for more info.
    • replaceDuplicatePlugins: Defaults to false. If true, the plugins in custom webpack config will replace the corresponding plugins in default Angular CLI webpack configuration.

angular.json Example:

"architect": {
    ...
    "build": {
              "builder": "@angular-builders/custom-webpack:server"
              "options": {
                     "customWebpackConfig": {
                        path: "./extra-webpack.config.js",
                        mergeStrategies: { "loaders": "replace" },
                        replaceDuplicatePlugins: true
                     }
                    "outputPath": "dist/my-cool-server",
                    "main": "src/main.server.ts",
                    "tsConfig": "src/tsconfig.server.json"
              }

In this example loaders entry from Angular CLI webpack config will be replaced with loaders entry from extra-webpack.config.js. The plugins from extra-webpack.config.js will override the corresponding plugins from Angular CLI webpack config.

Further reading

17.0.3-beta.1

10 days ago

17.0.3-beta.0

15 days ago

17.0.2

18 days ago

17.0.2-beta.1

1 month ago

17.0.2-beta.0

1 month ago

17.0.1

2 months ago

17.0.1-beta.1

3 months ago

17.0.1-beta.0

3 months ago

18.0.0-beta.1

5 months ago

18.0.0-beta.0

5 months ago

17.0.0-beta.0

5 months ago

17.0.0

5 months ago

16.0.1-beta.2

10 months ago

16.0.1-beta.1

10 months ago

16.0.2-beta.2

7 months ago

16.0.2-beta.0

8 months ago

16.0.2-beta.1

8 months ago

16.0.1

8 months ago

16.0.1-beta.0

10 months ago

16.0.0-beta.2

11 months ago

16.0.0

11 months ago

16.0.0-beta.0

11 months ago

16.0.0-beta.1

11 months ago

14.1.0-beta.0

1 year ago

14.1.0

1 year ago

15.0.0

1 year ago

14.0.2-beta.0

1 year ago

15.0.0-beta.0

1 year ago

14.0.1-beta.1

2 years ago

14.0.1-beta.2

2 years ago

14.0.1

2 years ago

14.0.0-beta.0

2 years ago

14.0.1-beta.0

2 years ago

14.0.0

2 years ago

13.1.0-beta.0

2 years ago

13.1.0

2 years ago

13.0.1-beta.0

2 years ago

13.0.1-beta.1

2 years ago

13.0.1-beta.2

2 years ago

13.0.0

2 years ago

13.0.0-beta.0

2 years ago

13.0.0-beta.2

2 years ago

13.0.0-beta.1

2 years ago

12.1.3

3 years ago

12.1.3-beta.1

3 years ago

12.1.3-beta.0

3 years ago

12.1.2

3 years ago

12.1.2-beta.0

3 years ago

12.1.1

3 years ago

12.1.1-beta.0

3 years ago

12.1.0

3 years ago

12.1.0-beta.0

3 years ago

12.0.1-beta.0

3 years ago

12.0.0-beta.0

3 years ago

12.0.0

3 years ago

11.1.2-beta.0

3 years ago

11.1.1

3 years ago

11.1.1-beta.1

3 years ago

11.1.1-beta.0

3 years ago

11.1.0

3 years ago

11.1.0-beta.2

3 years ago

11.1.0-beta.1

3 years ago

11.1.0-beta.0

3 years ago

11.0.1-beta.4

3 years ago

11.0.1-beta.3

3 years ago

11.0.1-beta.2

3 years ago

11.0.1-beta.1

3 years ago

11.0.1-beta.0

3 years ago

11.0.0-beta.6

3 years ago

11.0.0

3 years ago

11.0.0-beta.5

3 years ago

11.0.0-beta.4

3 years ago

11.0.0-beta.3

3 years ago

11.0.0-beta.2

3 years ago

11.0.0-beta.1

3 years ago

11.0.0-beta.0

3 years ago

10.1.0-beta.0

4 years ago

10.0.1

4 years ago

10.0.2-beta.0

4 years ago

10.0.1-beta.1

4 years ago

10.0.1-beta.0

4 years ago

10.0.0

4 years ago

10.0.0-beta.1

4 years ago

10.0.0-beta.0

4 years ago

9.2.0

4 years ago

9.2.1-beta.0

4 years ago

9.2.0-beta.0

4 years ago

9.1.0

4 years ago

9.1.0-beta.1

4 years ago

9.1.0-beta.0

4 years ago

9.0.1-beta.0

4 years ago

9.0.0

4 years ago

9.0.0-beta.2

4 years ago

9.0.0-beta.1

4 years ago

9.0.0-beta.7

4 years ago

9.0.0-beta.6

4 years ago

9.0.0-beta.0

4 years ago

8.4.1

4 years ago

8.4.0

4 years ago

8.3.0

4 years ago

8.2.0

5 years ago

8.1.0

5 years ago

8.1.0-beta.0

5 years ago

8.0.2

5 years ago

7.5.2

5 years ago

7.5.1

5 years ago

7.5.0

5 years ago

8.0.1

5 years ago

8.0.0

5 years ago

8.0.0-RC.1

5 years ago

8.0.0-RC.0

5 years ago

8.0.0-beta.2

5 years ago

8.0.0-beta.1

5 years ago

7.4.3

5 years ago

7.4.2

5 years ago

7.4.1

5 years ago

7.3.1

5 years ago

7.4.0

5 years ago

7.3.0

5 years ago

7.2.0

5 years ago

7.1.1

5 years ago

7.0.0

5 years ago

6.0.0

5 years ago

2.5.4

6 years ago

2.5.3

6 years ago

2.5.2

6 years ago

2.5.1

6 years ago

2.5.0

6 years ago

2.4.1

6 years ago

2.4.0

6 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.3.0-beta.1

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago