Commit 4a894de8 authored by Evan You's avatar Evan You

fix: include query in loader dedupe

ref: vue-cli#2451
parent 20f359de
...@@ -63,14 +63,19 @@ module.exports.pitch = function (remainingRequest) { ...@@ -63,14 +63,19 @@ module.exports.pitch = function (remainingRequest) {
// also make sure to dedupe based on loader path. // also make sure to dedupe based on loader path.
// assumes you'd probably never want to apply the same loader on the same // assumes you'd probably never want to apply the same loader on the same
// file twice. // 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 seen = new Map()
const loaderStrings = [] const loaderStrings = []
loaders.forEach(loader => { 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 const request = typeof loader === 'string' ? loader : loader.request
if (!seen.has(type)) { if (!seen.has(identifier)) {
seen.set(type, true) seen.set(identifier, true)
// loader.request contains both the resolved loader path and its options // loader.request contains both the resolved loader path and its options
// query (e.g. ??ref-0) // query (e.g. ??ref-0)
loaderStrings.push(request) loaderStrings.push(request)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment