Skip to content

Commit

Permalink
🔧 cssModulesExcludes use RegExp (umijs#1511)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohuoni authored and sorrycc committed Nov 26, 2018
1 parent a2fde01 commit 3f89d3b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/af-webpack/src/getConfig/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,13 @@ export default function(webpackConfig, opts) {
if (opts.cssModulesExcludes) {
opts.cssModulesExcludes.forEach((exclude, index) => {
const rule = `cssModulesExcludes_${index}`;
const config = webpackConfig.module
.rule(rule)
.test(filePath => filePath.indexOf(exclude) > -1);
const config = webpackConfig.module.rule(rule).test(filePath => {
if (exclude instanceof RegExp) {
return exclude.test(filePath);
} else {
return filePath.indexOf(exclude) > -1;
}
});
const ext = extname(exclude).toLowerCase();
applyCSSRules(config, {
less: ext === '.less',
Expand Down

0 comments on commit 3f89d3b

Please sign in to comment.