Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b16311f

Browse files
clarkdoyyx990803
authored andcommittedApr 11, 2018
fix: reuse ident of css related loaders to avoid duplicates (#1233)
1 parent b983304 commit b16311f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed
 

‎lib/plugin.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,19 @@ function cloneRule (rule, normalizedRule) {
145145
return res
146146
}
147147

148-
const reuseIdentWhitelist = /css-loader/
148+
const reuseIdentWhitelist = [
149+
'css-loader',
150+
'(vue-)?style-loader',
151+
'postcss-loader',
152+
'extract-text-webpack-plugin',
153+
'mini-css-extract-plugin'
154+
]
155+
156+
const reuseIdentPattern = new RegExp(`(${reuseIdentWhitelist.join('|')})`)
149157

150158
function cleanIdent (use) {
151159
if (use.ident) {
152-
if (reuseIdentWhitelist.test(use.loader)) {
160+
if (reuseIdentPattern.test(use.loader)) {
153161
// Reuse options ident, so that imports from within css-loader would get the
154162
// exact same request prefixes, avoiding duplicated modules (#1199)
155163
use.options.ident = use.ident

1 commit comments

Comments
 (1)

pnbarx commented on May 14, 2018

@pnbarx

style-loader is not compatible with ident option since May 22, 2017, so it shouldn't match reuseIdentWhitelist rules.

Here is the style-loader options.json:
https://github.com/webpack-contrib/style-loader/blob/master/options.json
pay attention to "additionalProperties": false, so it doesn't allow to use ident option:

Module build failed: ValidationError: Style Loader Invalid Options
 
options['ident'] is an invalid additional property

Please sign in to comment.