@@ -213,6 +213,7 @@ class JsonWebpackSerializer {
213213 break ;
214214 case CircularDependencyPlugin :
215215 this . variableImports [ 'circular-dependency-plugin' ] = 'CircularDependencyPlugin' ;
216+ args . cwd = this . _escape ( 'projectRoot' ) ;
216217 break ;
217218 case AotPlugin :
218219 args = this . _aotPluginSerialize ( plugin ) ;
@@ -252,11 +253,13 @@ class JsonWebpackSerializer {
252253 // CopyWebpackPlugin doesn't have a constructor nor save args.
253254 this . variableImports [ 'copy-webpack-plugin' ] = 'CopyWebpackPlugin' ;
254255 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 ) ;
257258 }
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 ;
260263 } ) ;
261264 const patternsSerialized = serializer ( patternOptions ) ;
262265 const optionsSerialized = serializer ( plugin [ 'copyWebpackPluginOptions' ] ) || 'undefined' ;
@@ -303,7 +306,7 @@ class JsonWebpackSerializer {
303306 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 \/ / ) ) {
304307 return 'extract-text-webpack-plugin' ;
305308 } 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' ;
307310 }
308311 } else {
309312 if ( loader . loader ) {
@@ -315,7 +318,17 @@ class JsonWebpackSerializer {
315318 Object . keys ( args . variableImports )
316319 . forEach ( key => this . variableImports [ key ] = args . variableImports [ key ] ) ;
317320 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+ } ) ;
319332
320333 this . variables [ 'postcssPlugins' ] = loader . options . plugins ;
321334 loader . options . plugins = this . _escape ( 'postcssPlugins' ) ;
0 commit comments