@@ -225,6 +225,7 @@ class JsonWebpackSerializer {
225225 break ;
226226 case CircularDependencyPlugin :
227227 this . variableImports [ 'circular-dependency-plugin' ] = 'CircularDependencyPlugin' ;
228+ args . cwd = this . _escape ( 'projectRoot' ) ;
228229 break ;
229230 case AotPlugin :
230231 args = this . _aotPluginSerialize ( plugin ) ;
@@ -264,11 +265,13 @@ class JsonWebpackSerializer {
264265 // CopyWebpackPlugin doesn't have a constructor nor save args.
265266 this . variableImports [ 'copy-webpack-plugin' ] = 'CopyWebpackPlugin' ;
266267 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 ) ;
269270 }
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 ;
272275 } ) ;
273276 const patternsSerialized = serializer ( patternOptions ) ;
274277 const optionsSerialized = serializer ( plugin [ 'copyWebpackPluginOptions' ] ) || 'undefined' ;
@@ -315,7 +318,7 @@ class JsonWebpackSerializer {
315318 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 \/ / ) ) {
316319 return 'extract-text-webpack-plugin' ;
317320 } 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' ;
319322 }
320323 } else {
321324 if ( loader . loader ) {
@@ -327,7 +330,17 @@ class JsonWebpackSerializer {
327330 Object . keys ( args . variableImports )
328331 . forEach ( key => this . variableImports [ key ] = args . variableImports [ key ] ) ;
329332 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+ } ) ;
331344
332345 this . variables [ 'postcssPlugins' ] = loader . options . plugins ;
333346 loader . options . plugins = this . _escape ( 'postcssPlugins' ) ;
0 commit comments