@@ -213,6 +213,7 @@ class JsonWebpackSerializer {
213
213
break ;
214
214
case CircularDependencyPlugin :
215
215
this . variableImports [ 'circular-dependency-plugin' ] = 'CircularDependencyPlugin' ;
216
+ args . cwd = this . _escape ( 'projectRoot' ) ;
216
217
break ;
217
218
case AotPlugin :
218
219
args = this . _aotPluginSerialize ( plugin ) ;
@@ -252,11 +253,13 @@ class JsonWebpackSerializer {
252
253
// CopyWebpackPlugin doesn't have a constructor nor save args.
253
254
this . variableImports [ 'copy-webpack-plugin' ] = 'CopyWebpackPlugin' ;
254
255
const patternOptions = plugin [ 'copyWebpackPluginPatterns' ] . map ( ( pattern : any ) => {
255
- if ( ! pattern . context ) {
256
- return pattern ;
256
+ if ( pattern . context ) {
257
+ pattern . context = path . relative ( process . cwd ( ) , pattern . context ) ;
257
258
}
258
- const context = path . relative ( process . cwd ( ) , pattern . context ) ;
259
- return { ...pattern , context } ;
259
+ if ( pattern . from && pattern . from . glob ) {
260
+ pattern . from . glob = path . relative ( process . cwd ( ) , pattern . from . glob ) ;
261
+ }
262
+ return pattern ;
260
263
} ) ;
261
264
const patternsSerialized = serializer ( patternOptions ) ;
262
265
const optionsSerialized = serializer ( plugin [ 'copyWebpackPluginOptions' ] ) || 'undefined' ;
@@ -303,7 +306,7 @@ class JsonWebpackSerializer {
303
306
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 \/ / ) ) {
304
307
return 'extract-text-webpack-plugin' ;
305
308
} 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 / ) ) {
306
- // return '@ngtools/webpack';
309
+ return '@ngtools/webpack' ;
307
310
}
308
311
} else {
309
312
if ( loader . loader ) {
@@ -315,7 +318,17 @@ class JsonWebpackSerializer {
315
318
Object . keys ( args . variableImports )
316
319
. forEach ( key => this . variableImports [ key ] = args . variableImports [ key ] ) ;
317
320
Object . keys ( args . variables )
318
- . forEach ( key => this . variables [ key ] = JSON . stringify ( args . variables [ key ] ) ) ;
321
+ . forEach ( key => {
322
+ const value = args . variables [ key ] ;
323
+ if ( value === process . cwd ( ) ) {
324
+ this . variables [ key ] = 'process.cwd()' ;
325
+ } else if ( typeof value == 'string' && value . startsWith ( process . cwd ( ) ) ) {
326
+ this . variables [ key ] = 'process.cwd() + '
327
+ + JSON . stringify ( value . substr ( process . cwd ( ) . length ) ) ;
328
+ } else {
329
+ this . variables [ key ] = JSON . stringify ( value ) ;
330
+ }
331
+ } ) ;
319
332
320
333
this . variables [ 'postcssPlugins' ] = loader . options . plugins ;
321
334
loader . options . plugins = this . _escape ( 'postcssPlugins' ) ;
0 commit comments