@@ -16,23 +16,20 @@ const Warning = require('./Warning');
1616const CssSyntaxError = require ( './CssSyntaxError' ) ;
1717const { getLocalIdent } = require ( './utils' ) ;
1818
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 ;
2423
2524 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 ,
3027 } ;
3128
3229 const pipeline = postcss ( [
3330 modulesValues ,
3431 localByDefault ( {
35- mode : options . mode ,
32+ mode : loaderOptions . modules ? 'local' : 'global' ,
3633 rewriteUrl ( global , url ) {
3734 if ( parserOptions . url ) {
3835 // eslint-disable-next-line no-param-reassign
@@ -59,9 +56,9 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
5956 localIdentName ,
6057 exportName ,
6158 {
62- regExp : localIdentRegExp ,
63- hashPrefix : query . hashPrefix || '' ,
64- context,
59+ regExp : loaderOptions . localIdentRegExp ,
60+ hashPrefix : loaderOptions . hashPrefix || '' ,
61+ context : loaderOptions . context ,
6562 }
6663 ) ;
6764 } ,
@@ -70,13 +67,19 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
7067 ] ) ;
7168
7269 pipeline
73- . process ( inputSource , {
70+ . process ( content , {
7471 // 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 ( ) ,
7780 map : options . sourceMap
7881 ? {
79- prev : inputMap ,
82+ prev : map ,
8083 sourcesContent : true ,
8184 inline : false ,
8285 annotation : false ,
@@ -86,9 +89,7 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
8689 . then ( ( result ) => {
8790 result
8891 . warnings ( )
89- . forEach ( ( warning ) =>
90- options . loaderContext . emitWarning ( new Warning ( warning ) )
91- ) ;
92+ . forEach ( ( warning ) => loaderContext . emitWarning ( new Warning ( warning ) ) ) ;
9293
9394 callback ( null , {
9495 source : result . css ,
0 commit comments