File tree Expand file tree Collapse file tree 8 files changed +1668
-943
lines changed Expand file tree Collapse file tree 8 files changed +1668
-943
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ Extend the Angular CLI's default build behavior without ejecting:
44
55- 📦 Build a single bundle (e. g. for Angular Elements)
66- 📄 Extend the default behavior by providing a ** partial** config that just contains your additional settings
7+ - 📄 Alternative: Extend the default behavior by providing a custom function
78- ☑️ Inherits from the default builder, hence you have the same options
89- 🍰 Simple to use
910- ⏏️ No eject needed
@@ -208,4 +209,28 @@ declare let VERSION: string;
208209console .debug (' VERSION' , VERSION );
209210```
210211
212+ ## Using a custom function to modify the webpack config
211213
214+ For more advanced modifications you can provide a function that gets the webpack config passed and returns the modified one.
215+
216+ Follow the following steps to try it out:
217+
218+ 1 . Add a file with a config hook to your project (`` hook/hook.ts `` ):
219+
220+ ``` typescript
221+ export default (cfg ) => {
222+ console .debug (' config' , cfg );
223+ // mess around with wepback config here ...
224+ return cfg ;
225+ }
226+ ```
227+
228+ 2. Compile your solution using ` ` tsc ` ` .
229+
230+ 3. Use the ` ` configHook ` ` switch to point to the compiled version of your hook :
231+
232+ ```
233+ ng build -- configHook ~ dist / out - tsc / hook / hook
234+ ```
235+
236+ The prefix ` ` ~ ` ` is replaced with your current directory . If you don ' t use it, it points to a installed ``node_module``.
Original file line number Diff line number Diff line change 11{
22 "name" : " ngx-build-plus" ,
3- "version" : " 6.2 .0" ,
3+ "version" : " 7.0 .0" ,
44 "description" : " Extensible Builder for the Angular CLI suitable not only for Angular Elements." ,
55 "license" : " MIT" ,
66 "repository" : {
2121 "webpack-merge" : " ^4.1.2"
2222 },
2323 "peerDependencies" : {
24- "@angular-devkit/architect" : " ^0.7.1 " ,
25- "@angular-devkit/build-angular" : " ^0.7.1 " ,
26- "@angular-devkit/core" : " ^0.7.1 " ,
24+ "@angular-devkit/architect" : " ~0.10.0 " ,
25+ "@angular-devkit/build-angular" : " ~0.10.0 " ,
26+ "@angular-devkit/core" : " ~0.10.0 " ,
2727 "rxjs" : " ^6.0.0"
2828 },
2929 "devDependencies" : {
Original file line number Diff line number Diff line change 77 */
88
99export * from './plus' ;
10- export * from './plus-dev-server' ;
10+ export * from './plus-dev-server' ;
11+ export * from './ext/hook' ;
Original file line number Diff line number Diff line change @@ -34,7 +34,13 @@ export class PlusBuilder extends BrowserBuilder {
3434 }
3535
3636 if ( options . configHook ) {
37- const hook = require ( options . configHook ) . default as ConfigHookFn ;
37+ let configHook = options . configHook ;
38+
39+ if ( configHook . startsWith ( '~' ) ) {
40+ configHook = process . cwd ( ) + '/' + configHook . substr ( 1 ) ;
41+ }
42+
43+ const hook = require ( configHook ) . default as ConfigHookFn ;
3844 config = hook ( config ) ;
3945 }
4046
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ Extend the Angular CLI's default build behavior without ejecting:
44
55- 📦 Build a single bundle (e. g. for Angular Elements)
66- 📄 Extend the default behavior by providing a ** partial** config that just contains your additional settings
7+ - 📄 Alternative: Extend the default behavior by providing a custom function
78- ☑️ Inherits from the default builder, hence you have the same options
89- 🍰 Simple to use
910- ⏏️ No eject needed
@@ -208,4 +209,28 @@ declare let VERSION: string;
208209console .debug (' VERSION' , VERSION );
209210```
210211
212+ ## Using a custom function to modify the webpack config
211213
214+ For more advanced modifications you can provide a function that gets the webpack config passed and returns the modified one.
215+
216+ Follow the following steps to try it out:
217+
218+ 1 . Add a file with a config hook to your project (`` hook/hook.ts `` ):
219+
220+ ``` typescript
221+ export default (cfg ) => {
222+ console .debug (' config' , cfg );
223+ // mess around with wepback config here ...
224+ return cfg ;
225+ }
226+ ```
227+
228+ 2. Compile your solution using ` ` tsc ` ` .
229+
230+ 3. Use the ` ` configHook ` ` switch to point to the compiled version of your hook :
231+
232+ ```
233+ ng build -- configHook ~ dist / out - tsc / hook / hook
234+ ```
235+
236+ The prefix ` ` ~ ` ` is replaced with your current directory . If you don ' t use it, it points to a installed ``node_module``.
Original file line number Diff line number Diff line change 1+ export default ( cfg ) => {
2+ console . debug ( 'config' , cfg ) ;
3+ return cfg ;
4+ }
You can’t perform that action at this time.
0 commit comments