Skip to content

Commit

Permalink
fix: include query in loader dedupe
Browse files Browse the repository at this point in the history
ref: vue-cli#2451
  • Loading branch information
yyx990803 committed Sep 11, 2018
1 parent 20f359d commit 4a894de
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/loaders/pitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,19 @@ module.exports.pitch = function (remainingRequest) {
// also make sure to dedupe based on loader path.
// assumes you'd probably never want to apply the same loader on the same
// file twice.
// Exception: in Vue CLI we do need two instances of postcss-loader
// for user config and inline minification. So we need to dedupe baesd on
// path AND query to be safe.
const seen = new Map()
const loaderStrings = []

loaders.forEach(loader => {
const type = typeof loader === 'string' ? loader : loader.path
const identifier = typeof loader === 'string'
? loader
: (loader.path + loader.query)
const request = typeof loader === 'string' ? loader : loader.request
if (!seen.has(type)) {
seen.set(type, true)
if (!seen.has(identifier)) {
seen.set(identifier, true)
// loader.request contains both the resolved loader path and its options
// query (e.g. ??ref-0)
loaderStrings.push(request)
Expand Down

0 comments on commit 4a894de

Please sign in to comment.