@@ -14,16 +14,16 @@ import {
14
14
import * as path from 'path' ;
15
15
import { AngularCompilerPlugin } from '@ngtools/webpack' ;
16
16
17
- export interface WebpackConfigOptions {
17
+ export interface WebpackConfigOptions < T extends BuildOptions = BuildOptions > {
18
18
projectRoot : string ;
19
- buildOptions : BuildOptions ;
19
+ buildOptions : T ;
20
20
appConfig : any ;
21
21
}
22
22
23
- export class NgCliWebpackConfig {
23
+ export class NgCliWebpackConfig < T extends BuildOptions = BuildOptions > {
24
24
public config : any ;
25
- public wco : WebpackConfigOptions ;
26
- constructor ( buildOptions : BuildOptions , appConfig : any ) {
25
+ public wco : WebpackConfigOptions < T > ;
26
+ constructor ( buildOptions : T , appConfig : any ) {
27
27
28
28
this . validateBuildOptions ( buildOptions ) ;
29
29
@@ -59,7 +59,7 @@ export class NgCliWebpackConfig {
59
59
return this . config ;
60
60
}
61
61
62
- public getTargetConfig ( webpackConfigOptions : WebpackConfigOptions ) : any {
62
+ public getTargetConfig ( webpackConfigOptions : WebpackConfigOptions < T > ) : any {
63
63
switch ( webpackConfigOptions . buildOptions . target ) {
64
64
case 'development' :
65
65
return getDevConfig ( webpackConfigOptions ) ;
@@ -86,8 +86,8 @@ export class NgCliWebpackConfig {
86
86
}
87
87
88
88
// Fill in defaults for build targets
89
- public addTargetDefaults ( buildOptions : BuildOptions ) : BuildOptions {
90
- const targetDefaults : { [ target : string ] : BuildOptions } = {
89
+ public addTargetDefaults ( buildOptions : T ) : T {
90
+ const targetDefaults : { [ target : string ] : Partial < BuildOptions > } = {
91
91
development : {
92
92
environment : 'dev' ,
93
93
outputHashing : 'media' ,
@@ -110,8 +110,8 @@ export class NgCliWebpackConfig {
110
110
}
111
111
112
112
// Fill in defaults from .angular-cli.json
113
- public mergeConfigs ( buildOptions : BuildOptions , appConfig : any , projectRoot : string ) {
114
- const mergeableOptions = {
113
+ public mergeConfigs ( buildOptions : T , appConfig : any , projectRoot : string ) : T {
114
+ const mergeableOptions : Partial < BuildOptions > = {
115
115
outputPath : path . resolve ( projectRoot , appConfig . outDir ) ,
116
116
deployUrl : appConfig . deployUrl ,
117
117
baseHref : appConfig . baseHref
0 commit comments