Skip to content

Commit f070f6b

Browse files
authored
Remove CSS Modules postcss plugins in Global mode
Fixes webpack-contrib#308
1 parent 9d2941b commit f070f6b

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

lib/processCss.js

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -147,33 +147,40 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
147147
import: query.import !== false
148148
};
149149

150-
var pipeline = postcss([
151-
localByDefault({
152-
mode: options.mode,
153-
rewriteUrl: function(global, url) {
154-
if(parserOptions.url){
155-
if(!loaderUtils.isUrlRequest(url, root)) {
156-
return url;
157-
}
158-
if(global) {
159-
return loaderUtils.urlToRequest(url, root);
150+
var pipeline = postcss(
151+
(options.mode === 'local' ? [
152+
/* LOCAL ONLY POSTCSS PLUGINS */
153+
localByDefault({
154+
mode: options.mode,
155+
rewriteUrl: function(global, url) {
156+
if(parserOptions.url){
157+
if(!loaderUtils.isUrlRequest(url, root)) {
158+
return url;
159+
}
160+
if(global) {
161+
return loaderUtils.urlToRequest(url, root);
162+
}
160163
}
164+
return url;
161165
}
162-
return url;
163-
}
164-
}),
165-
extractImports(),
166-
modulesValues,
167-
modulesScope({
168-
generateScopedName: function(exportName) {
169-
return getLocalIdent(options.loaderContext, localIdentName, exportName, {
170-
regExp: localIdentRegExp,
171-
hashPrefix: query.hashPrefix || "",
172-
context: context
173-
});
174-
}
175-
}),
176-
parserPlugin(parserOptions)
166+
}),
167+
extractImports(),
168+
modulesValues,
169+
modulesScope({
170+
generateScopedName: function(exportName) {
171+
return getLocalIdent(options.loaderContext, localIdentName, exportName, {
172+
regExp: localIdentRegExp,
173+
hashPrefix: query.hashPrefix || "",
174+
context: context
175+
});
176+
}
177+
})
178+
] : [
179+
/* GLOBAL ONLY POSTCSS PLUGINS */
180+
]).concat([
181+
/* COMMON POSTCSS PLUGINS */
182+
parserPlugin(parserOptions)
183+
])
177184
]);
178185

179186
if(minimize) {

0 commit comments

Comments
 (0)