@@ -6,6 +6,7 @@ import loaderUtils from 'loader-utils';
66import cacache from 'cacache' ;
77import serialize from 'serialize-javascript' ;
88import findCacheDir from 'find-cache-dir' ;
9+ import normalizePath from 'normalize-path' ;
910
1011import { name , version } from '../package.json' ;
1112
@@ -138,26 +139,29 @@ export default function postProcessPattern(globalRef, pattern, file) {
138139 `transforming path '${ file . webpackTo } ' for '${ file . absoluteFrom } '`
139140 ) ;
140141
141- return Promise . resolve (
142- pattern . transformPath ( file . webpackTo , file . absoluteFrom )
143- )
142+ return Promise . resolve ( )
143+ . then ( ( ) =>
144+ pattern . transformPath ( file . webpackTo , file . absoluteFrom )
145+ )
144146 . then ( ( newPath ) => {
145- // Developers can use invalid slashes we should fix it
146- file . webpackTo = path . normalize ( newPath ) ;
147- } )
148- . then ( ( ) => content ) ;
147+ file . webpackTo = newPath ;
148+
149+ return content ;
150+ } ) ;
149151 }
150152
151153 return content ;
152154 } )
153155 . then ( ( content ) => {
154156 const hash = loaderUtils . getHashDigest ( content ) ;
157+ const targetPath = normalizePath ( file . webpackTo ) ;
158+ const targetAbsolutePath = normalizePath ( file . absoluteFrom ) ;
155159
156160 if (
157161 ! copyUnmodified &&
158- written [ file . webpackTo ] &&
159- written [ file . webpackTo ] [ file . absoluteFrom ] &&
160- written [ file . webpackTo ] [ file . absoluteFrom ] === hash
162+ written [ targetPath ] &&
163+ written [ targetPath ] [ targetAbsolutePath ] &&
164+ written [ targetPath ] [ targetAbsolutePath ] === hash
161165 ) {
162166 logger . info (
163167 `skipping '${ file . webpackTo } ', because content hasn't changed`
@@ -168,13 +172,13 @@ export default function postProcessPattern(globalRef, pattern, file) {
168172
169173 logger . debug ( `adding '${ file . webpackTo } ' for tracking content changes` ) ;
170174
171- if ( ! written [ file . webpackTo ] ) {
172- written [ file . webpackTo ] = { } ;
175+ if ( ! written [ targetPath ] ) {
176+ written [ targetPath ] = { } ;
173177 }
174178
175- written [ file . webpackTo ] [ file . absoluteFrom ] = hash ;
179+ written [ targetPath ] [ targetAbsolutePath ] = hash ;
176180
177- if ( compilation . assets [ file . webpackTo ] && ! file . force ) {
181+ if ( compilation . assets [ targetPath ] && ! file . force ) {
178182 logger . info (
179183 `skipping '${ file . webpackTo } ', because it already exists`
180184 ) ;
@@ -186,7 +190,7 @@ export default function postProcessPattern(globalRef, pattern, file) {
186190 `writing '${ file . webpackTo } ' to compilation assets from '${ file . absoluteFrom } '`
187191 ) ;
188192
189- compilation . assets [ file . webpackTo ] = {
193+ compilation . assets [ targetPath ] = {
190194 size ( ) {
191195 return stats . size ;
192196 } ,
0 commit comments