@@ -192,18 +192,45 @@ function getPostcssOptions(loaderContext, config, postcssOptions = {}) {
192
192
193
193
const processOptionsFromConfig = { ...config } ;
194
194
195
+ if ( processOptionsFromConfig . from ) {
196
+ processOptionsFromConfig . from = path . resolve (
197
+ path . dirname ( config . file ) ,
198
+ processOptionsFromConfig . from
199
+ ) ;
200
+ }
201
+
202
+ if ( processOptionsFromConfig . to ) {
203
+ processOptionsFromConfig . to = path . resolve (
204
+ path . dirname ( config . file ) ,
205
+ processOptionsFromConfig . to
206
+ ) ;
207
+ }
208
+
195
209
// No need them for processOptions
196
210
delete processOptionsFromConfig . plugins ;
197
211
delete processOptionsFromConfig . file ;
198
212
199
213
const processOptionsFromOptions = { ...normalizedPostcssOptions } ;
200
214
215
+ if ( processOptionsFromOptions . from ) {
216
+ processOptionsFromOptions . from = path . resolve (
217
+ loaderContext . rootContext ,
218
+ processOptionsFromOptions . from
219
+ ) ;
220
+ }
221
+
222
+ if ( processOptionsFromOptions . to ) {
223
+ processOptionsFromOptions . to = path . resolve (
224
+ loaderContext . rootContext ,
225
+ processOptionsFromOptions . to
226
+ ) ;
227
+ }
228
+
201
229
// No need them for processOptions
202
230
delete processOptionsFromOptions . config ;
203
231
delete processOptionsFromOptions . plugins ;
204
232
205
233
const processOptions = {
206
- // TODO path.resolve
207
234
from : file ,
208
235
to : file ,
209
236
map : false ,
@@ -272,7 +299,7 @@ function getURLType(source) {
272
299
return ABSOLUTE_SCHEME . test ( source ) ? 'absolute' : 'path-relative' ;
273
300
}
274
301
275
- function normalizeSourceMap ( map , resourcePath ) {
302
+ function normalizeSourceMap ( map , resourceContext ) {
276
303
let newMap = map ;
277
304
278
305
// Some loader emit source map as string
@@ -298,7 +325,7 @@ function normalizeSourceMap(map, resourcePath) {
298
325
? path . resolve ( sourceRoot , path . normalize ( source ) )
299
326
: path . normalize ( source ) ;
300
327
301
- return path . relative ( path . dirname ( resourcePath ) , absoluteSource ) ;
328
+ return path . relative ( resourceContext , absoluteSource ) ;
302
329
}
303
330
304
331
return source ;
@@ -308,7 +335,7 @@ function normalizeSourceMap(map, resourcePath) {
308
335
return newMap ;
309
336
}
310
337
311
- function normalizeSourceMapAfterPostcss ( map , resourcePath ) {
338
+ function normalizeSourceMapAfterPostcss ( map , resourceContext ) {
312
339
const newMap = map ;
313
340
314
341
// result.map.file is an optional property that provides the output filename.
@@ -329,9 +356,7 @@ function normalizeSourceMapAfterPostcss(map, resourcePath) {
329
356
330
357
// Do no touch `scheme-relative`, `path-absolute` and `absolute` types
331
358
if ( sourceType === 'path-relative' ) {
332
- const dirname = path . dirname ( resourcePath ) ;
333
-
334
- return path . resolve ( dirname , source ) ;
359
+ return path . resolve ( resourceContext , source ) ;
335
360
}
336
361
337
362
return source ;
0 commit comments