File tree 3 files changed +46
-7
lines changed
packages/angular_devkit/build_angular/src/server 3 files changed +46
-7
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import {
37
37
import { BuildWebpackServerSchema } from './schema' ;
38
38
const webpackMerge = require ( 'webpack-merge' ) ;
39
39
40
+ import { addFileReplacements } from '../utils' ;
40
41
41
42
export class ServerBuilder implements Builder < BuildWebpackServerSchema > {
42
43
@@ -46,12 +47,14 @@ export class ServerBuilder implements Builder<BuildWebpackServerSchema> {
46
47
const options = builderConfig . options ;
47
48
const root = this . context . workspace . root ;
48
49
const projectRoot = resolve ( root , builderConfig . root ) ;
50
+ const host = new virtualFs . AliasHost ( this . context . host as virtualFs . Host < Stats > ) ;
49
51
50
52
// TODO: verify using of(null) to kickstart things is a pattern.
51
53
return of ( null ) . pipe (
52
54
concatMap ( ( ) => options . deleteOutputPath
53
55
? this . _deleteOutputDir ( root , normalize ( options . outputPath ) )
54
56
: of ( null ) ) ,
57
+ concatMap ( ( ) => addFileReplacements ( root , host , options . fileReplacements ) ) ,
55
58
concatMap ( ( ) => new Observable ( obs => {
56
59
// Ensure Build Optimizer is only used with AOT.
57
60
let webpackConfig ;
Original file line number Diff line number Diff line change @@ -70,9 +70,9 @@ export interface BuildWebpackServerSchema {
70
70
*/
71
71
lazyModules ?: string [ ] ;
72
72
/**
73
- * Defines the build environment .
73
+ * Replace files with other files in the build.
74
74
*/
75
- environment ?: string ;
75
+ fileReplacements : FileReplacements [ ] ;
76
76
/**
77
77
* Define the output filename cache-busting hashing mode.
78
78
*/
Original file line number Diff line number Diff line change 32
32
"description" : " Defines the optimization level of the build." ,
33
33
"default" : false
34
34
},
35
- "environment" : {
36
- "type" : " string" ,
37
- "description" : " Defines the build environment."
35
+ "fileReplacements" : {
36
+ "description" : " Replace files with other files in the build." ,
37
+ "type" : " array" ,
38
+ "items" : {
39
+ "$ref" : " #/definitions/fileReplacement"
40
+ },
41
+ "default" : []
38
42
},
39
43
"outputPath" : {
40
44
"type" : " string" ,
155
159
" outputPath" ,
156
160
" main" ,
157
161
" tsConfig"
158
- ]
159
- }
162
+ ],
163
+ "definitions" : {
164
+ "fileReplacement" : {
165
+ "oneOf" : [
166
+ {
167
+ "type" : " object" ,
168
+ "properties" : {
169
+ "src" : {
170
+ "type" : " string"
171
+ },
172
+ "replaceWith" : {
173
+ "type" : " string"
174
+ }
175
+ },
176
+ "additionalProperties" : false ,
177
+ "required" : [" src" , " replaceWith" ]
178
+ },
179
+ {
180
+ "type" : " object" ,
181
+ "properties" : {
182
+ "replace" : {
183
+ "type" : " string"
184
+ },
185
+ "with" : {
186
+ "type" : " string"
187
+ }
188
+ },
189
+ "additionalProperties" : false ,
190
+ "required" : [" replace" , " with" ]
191
+ }
192
+ ]
193
+ }
194
+ }
195
+ }
You can’t perform that action at this time.
0 commit comments