@@ -6,6 +6,7 @@ import loaderUtils from 'loader-utils';
6
6
import cacache from 'cacache' ;
7
7
import serialize from 'serialize-javascript' ;
8
8
import findCacheDir from 'find-cache-dir' ;
9
+ import normalizePath from 'normalize-path' ;
9
10
10
11
import { name , version } from '../package.json' ;
11
12
@@ -138,26 +139,29 @@ export default function postProcessPattern(globalRef, pattern, file) {
138
139
`transforming path '${ file . webpackTo } ' for '${ file . absoluteFrom } '`
139
140
) ;
140
141
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
+ )
144
146
. 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
+ } ) ;
149
151
}
150
152
151
153
return content ;
152
154
} )
153
155
. then ( ( content ) => {
154
156
const hash = loaderUtils . getHashDigest ( content ) ;
157
+ const targetPath = normalizePath ( file . webpackTo ) ;
158
+ const targetAbsolutePath = normalizePath ( file . absoluteFrom ) ;
155
159
156
160
if (
157
161
! 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
161
165
) {
162
166
logger . info (
163
167
`skipping '${ file . webpackTo } ', because content hasn't changed`
@@ -168,13 +172,13 @@ export default function postProcessPattern(globalRef, pattern, file) {
168
172
169
173
logger . debug ( `adding '${ file . webpackTo } ' for tracking content changes` ) ;
170
174
171
- if ( ! written [ file . webpackTo ] ) {
172
- written [ file . webpackTo ] = { } ;
175
+ if ( ! written [ targetPath ] ) {
176
+ written [ targetPath ] = { } ;
173
177
}
174
178
175
- written [ file . webpackTo ] [ file . absoluteFrom ] = hash ;
179
+ written [ targetPath ] [ targetAbsolutePath ] = hash ;
176
180
177
- if ( compilation . assets [ file . webpackTo ] && ! file . force ) {
181
+ if ( compilation . assets [ targetPath ] && ! file . force ) {
178
182
logger . info (
179
183
`skipping '${ file . webpackTo } ', because it already exists`
180
184
) ;
@@ -186,7 +190,7 @@ export default function postProcessPattern(globalRef, pattern, file) {
186
190
`writing '${ file . webpackTo } ' to compilation assets from '${ file . absoluteFrom } '`
187
191
) ;
188
192
189
- compilation . assets [ file . webpackTo ] = {
193
+ compilation . assets [ targetPath ] = {
190
194
size ( ) {
191
195
return stats . size ;
192
196
} ,
0 commit comments