Skip to content

Commit

Permalink
fix: reuse ident of css related loaders to avoid duplicates (#1233)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo authored and yyx990803 committed Apr 11, 2018
1 parent b983304 commit b16311f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,19 @@ function cloneRule (rule, normalizedRule) {
return res
}

const reuseIdentWhitelist = /css-loader/
const reuseIdentWhitelist = [
'css-loader',
'(vue-)?style-loader',
'postcss-loader',
'extract-text-webpack-plugin',
'mini-css-extract-plugin'
]

const reuseIdentPattern = new RegExp(`(${reuseIdentWhitelist.join('|')})`)

function cleanIdent (use) {
if (use.ident) {
if (reuseIdentWhitelist.test(use.loader)) {
if (reuseIdentPattern.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
Expand Down

1 comment on commit b16311f

@pnbarx
Copy link

@pnbarx pnbarx commented on b16311f May 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.