Skip to content

Commit

Permalink
fix: only reuse ident for whitelisted loaders
Browse files Browse the repository at this point in the history
fix #1214
  • Loading branch information
yyx990803 committed Mar 24, 2018
1 parent 05dceec commit 230abd4
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function cloneRule (rule, normalizedRule) {
}
return true
},
use: normalizedRule.use ? normalizedRule.use.map(reuseIdent) : undefined
use: normalizedRule.use ? normalizedRule.use.map(cleanIdent) : undefined
})

// delete shorthand since we have normalized use
Expand All @@ -138,16 +138,15 @@ function cloneRule (rule, normalizedRule) {
return res
}

// Some loaders like babel-loader passes its own option directly to babel
// and since babel validates the options, "ident" would cause an unknown option
// error. For these loaders we'll bail out on the ident reuse.
const reuseIdentBlackList = /babel-loader/
const reuseIdentWhitelist = /css-loader/

// Reuse options ident, so that imports from within css-loader would get the
// exact same request prefixes, avoiding duplicated modules (#1199)
function reuseIdent (use) {
if (use.ident && !reuseIdentBlackList.test(use.loader)) {
use.options.ident = use.ident
function cleanIdent (use) {
if (use.ident) {
if (reuseIdentWhitelist.test(use.loader)) {
// Reuse options ident, so that imports from within css-loader would get the
// exact same request prefixes, avoiding duplicated modules (#1199)
use.options.ident = use.ident
}
delete use.ident
}
return use
Expand Down

0 comments on commit 230abd4

Please sign in to comment.