@@ -182,27 +182,37 @@ function getCommonConfig(wco) {
182182 if ( buildOptions . assets . length ) {
183183 const copyWebpackPluginPatterns = buildOptions . assets . map ( ( asset ) => {
184184 // Resolve input paths relative to workspace root and add slash at the end.
185- asset . input = path . resolve ( root , asset . input ) . replace ( / \\ / g, '/' ) ;
186- asset . input = asset . input . endsWith ( '/' ) ? asset . input : asset . input + '/' ;
187- asset . output = asset . output . endsWith ( '/' ) ? asset . output : asset . output + '/' ;
188- if ( asset . output . startsWith ( '..' ) ) {
189- const message = 'An asset cannot be written to a location outside of the output path.' ;
190- throw new Error ( message ) ;
185+ // tslint:disable-next-line: prefer-const
186+ let { input, output, ignore = [ ] , glob } = asset ;
187+ input = path . resolve ( root , input ) . replace ( / \\ / g, '/' ) ;
188+ input = input . endsWith ( '/' ) ? input : input + '/' ;
189+ output = output . endsWith ( '/' ) ? output : output + '/' ;
190+ if ( output . startsWith ( '..' ) ) {
191+ throw new Error ( 'An asset cannot be written to a location outside of the output path.' ) ;
191192 }
192193 return {
193- context : asset . input ,
194+ context : input ,
194195 // Now we remove starting slash to make Webpack place it from the output root.
195- to : asset . output . replace ( / ^ \/ / , '' ) ,
196- ignore : asset . ignore ,
197- from : {
198- glob : asset . glob ,
196+ to : output . replace ( / ^ \/ / , '' ) ,
197+ from : glob ,
198+ noErrorOnMissing : true ,
199+ globOptions : {
199200 dot : true ,
201+ ignore : [
202+ '.gitkeep' ,
203+ '**/.DS_Store' ,
204+ '**/Thumbs.db' ,
205+ // Negate patterns needs to be absolute because copy-webpack-plugin uses absolute globs which
206+ // causes negate patterns not to match.
207+ // See: https://github.com/webpack-contrib/copy-webpack-plugin/issues/498#issuecomment-639327909
208+ ...ignore ,
209+ ] . map ( i => path . posix . join ( input , i ) ) ,
200210 } ,
201211 } ;
202212 } ) ;
203- const copyWebpackPluginOptions = { ignore : [ '.gitkeep' , '**/.DS_Store' , '**/Thumbs.db' ] } ;
204- const copyWebpackPluginInstance = new CopyWebpackPlugin ( copyWebpackPluginPatterns , copyWebpackPluginOptions ) ;
205- extraPlugins . push ( copyWebpackPluginInstance ) ;
213+ extraPlugins . push ( new CopyWebpackPlugin ( {
214+ patterns : copyWebpackPluginPatterns ,
215+ } ) ) ;
206216 }
207217 if ( buildOptions . progress ) {
208218 extraPlugins . push ( new ProgressPlugin ( { profile : buildOptions . verbose } ) ) ;
0 commit comments