@@ -225,6 +225,7 @@ class JsonWebpackSerializer {
225
225
break ;
226
226
case CircularDependencyPlugin :
227
227
this . variableImports [ 'circular-dependency-plugin' ] = 'CircularDependencyPlugin' ;
228
+ args . cwd = this . _escape ( 'projectRoot' ) ;
228
229
break ;
229
230
case AotPlugin :
230
231
args = this . _aotPluginSerialize ( plugin ) ;
@@ -264,11 +265,13 @@ class JsonWebpackSerializer {
264
265
// CopyWebpackPlugin doesn't have a constructor nor save args.
265
266
this . variableImports [ 'copy-webpack-plugin' ] = 'CopyWebpackPlugin' ;
266
267
const patternOptions = plugin [ 'copyWebpackPluginPatterns' ] . map ( ( pattern : any ) => {
267
- if ( ! pattern . context ) {
268
- return pattern ;
268
+ if ( pattern . context ) {
269
+ pattern . context = path . relative ( process . cwd ( ) , pattern . context ) ;
269
270
}
270
- const context = path . relative ( process . cwd ( ) , pattern . context ) ;
271
- return { ...pattern , context } ;
271
+ if ( pattern . from && pattern . from . glob ) {
272
+ pattern . from . glob = path . relative ( process . cwd ( ) , pattern . from . glob ) ;
273
+ }
274
+ return pattern ;
272
275
} ) ;
273
276
const patternsSerialized = serializer ( patternOptions ) ;
274
277
const optionsSerialized = serializer ( plugin [ 'copyWebpackPluginOptions' ] ) || 'undefined' ;
@@ -315,7 +318,7 @@ class JsonWebpackSerializer {
315
318
if ( loader . match ( / \/ n o d e _ m o d u l e s \/ e x t r a c t - t e x t - w e b p a c k - p l u g i n \/ / ) ) {
316
319
return 'extract-text-webpack-plugin' ;
317
320
} else if ( loader . match ( / @ n g t o o l s \/ w e b p a c k \/ s r c \/ i n d e x .t s / ) ) {
318
- // return '@ngtools/webpack';
321
+ return '@ngtools/webpack' ;
319
322
}
320
323
} else {
321
324
if ( loader . loader ) {
@@ -327,7 +330,17 @@ class JsonWebpackSerializer {
327
330
Object . keys ( args . variableImports )
328
331
. forEach ( key => this . variableImports [ key ] = args . variableImports [ key ] ) ;
329
332
Object . keys ( args . variables )
330
- . forEach ( key => this . variables [ key ] = JSON . stringify ( args . variables [ key ] ) ) ;
333
+ . forEach ( key => {
334
+ const value = args . variables [ key ] ;
335
+ if ( value === process . cwd ( ) ) {
336
+ this . variables [ key ] = 'process.cwd()' ;
337
+ } else if ( typeof value == 'string' && value . startsWith ( process . cwd ( ) ) ) {
338
+ this . variables [ key ] = 'process.cwd() + '
339
+ + JSON . stringify ( value . substr ( process . cwd ( ) . length ) ) ;
340
+ } else {
341
+ this . variables [ key ] = JSON . stringify ( value ) ;
342
+ }
343
+ } ) ;
331
344
332
345
this . variables [ 'postcssPlugins' ] = loader . options . plugins ;
333
346
loader . options . plugins = this . _escape ( 'postcssPlugins' ) ;
0 commit comments