@@ -16,23 +16,20 @@ const Warning = require('./Warning');
16
16
const CssSyntaxError = require ( './CssSyntaxError' ) ;
17
17
const { getLocalIdent } = require ( './utils' ) ;
18
18
19
- module . exports = function processCss ( inputSource , inputMap , options , callback ) {
20
- const { query } = options ;
21
- const { context, localIdentRegExp } = query ;
22
- const localIdentName = query . localIdentName || '[hash:base64]' ;
23
- const customGetLocalIdent = query . getLocalIdent || getLocalIdent ;
19
+ module . exports = function processCss ( content , map , options , callback ) {
20
+ const { loaderContext, loaderOptions } = options ;
21
+ const localIdentName = loaderOptions . localIdentName || '[hash:base64]' ;
22
+ const customGetLocalIdent = loaderOptions . getLocalIdent || getLocalIdent ;
24
23
25
24
const parserOptions = {
26
- mode : options . mode ,
27
- url : query . url !== false ,
28
- import : query . import !== false ,
29
- resolve : options . resolve ,
25
+ url : loaderOptions . url !== false ,
26
+ import : loaderOptions . import !== false ,
30
27
} ;
31
28
32
29
const pipeline = postcss ( [
33
30
modulesValues ,
34
31
localByDefault ( {
35
- mode : options . mode ,
32
+ mode : loaderOptions . modules ? 'local' : 'global' ,
36
33
rewriteUrl ( global , url ) {
37
34
if ( parserOptions . url ) {
38
35
// eslint-disable-next-line no-param-reassign
@@ -59,9 +56,9 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
59
56
localIdentName ,
60
57
exportName ,
61
58
{
62
- regExp : localIdentRegExp ,
63
- hashPrefix : query . hashPrefix || '' ,
64
- context,
59
+ regExp : loaderOptions . localIdentRegExp ,
60
+ hashPrefix : loaderOptions . hashPrefix || '' ,
61
+ context : loaderOptions . context ,
65
62
}
66
63
) ;
67
64
} ,
@@ -70,13 +67,19 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
70
67
] ) ;
71
68
72
69
pipeline
73
- . process ( inputSource , {
70
+ . process ( content , {
74
71
// we need a prefix to avoid path rewriting of PostCSS
75
- from : `/css-loader!${ options . from } ` ,
76
- to : options . to ,
72
+ from : `/css-loader!${ loaderUtils
73
+ . getRemainingRequest ( loaderContext )
74
+ . split ( '!' )
75
+ . pop ( ) } `,
76
+ to : loaderUtils
77
+ . getCurrentRequest ( loaderContext )
78
+ . split ( '!' )
79
+ . pop ( ) ,
77
80
map : options . sourceMap
78
81
? {
79
- prev : inputMap ,
82
+ prev : map ,
80
83
sourcesContent : true ,
81
84
inline : false ,
82
85
annotation : false ,
@@ -86,9 +89,7 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
86
89
. then ( ( result ) => {
87
90
result
88
91
. warnings ( )
89
- . forEach ( ( warning ) =>
90
- options . loaderContext . emitWarning ( new Warning ( warning ) )
91
- ) ;
92
+ . forEach ( ( warning ) => loaderContext . emitWarning ( new Warning ( warning ) ) ) ;
92
93
93
94
callback ( null , {
94
95
source : result . css ,
0 commit comments