Skip to content

Commit

Permalink
fix: Don't use rules that also match ".html"
Browse files Browse the repository at this point in the history
This adds a check so that rules that match foo.vue.html but *also* foo.html are ignored.

Resolves vuejs#1625
  • Loading branch information
ubipo committed Mar 22, 2021
1 parent b53ae44 commit 7238a44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/plugin-webpack4.js
Expand Up @@ -31,7 +31,12 @@ class VueLoaderPlugin {
// find the rule that applies to vue files
let vueRuleIndex = rawRules.findIndex(createMatcher(`foo.vue`))
if (vueRuleIndex < 0) {
vueRuleIndex = rawRules.findIndex(createMatcher(`foo.vue.html`))
const vueHtmlRuleIndex = rawRules.findIndex(createMatcher(`foo.vue.html`))
const htmlOnlyRuleIndex = rawRules.findIndex(createMatcher(`foo.html`))
// Only use the .vue.html rules if they don't also match normal .html files
if (vueHtmlRuleIndex !== -1 && htmlOnlyRuleIndex === -1) {
vueRuleIndex = vueHtmlRuleIndex
}
}
const vueRule = rules[vueRuleIndex]

Expand Down
9 changes: 8 additions & 1 deletion lib/plugin-webpack5.js
Expand Up @@ -60,9 +60,16 @@ class VueLoaderPlugin {
})

if (!vueRules.length) {
vueRules = ruleSet.exec({
const vueHtmlRules = ruleSet.exec({
resource: 'foo.vue.html'
})
const htmlOnlyRules = ruleSet.exec({
resource: 'foo.html'
})
// Only use the .vue.html rules if they don't also match normal .html files
if (vueHtmlRules.length > htmlOnlyRules.length) {
vueRules = vueHtmlRules
}
}
if (vueRules.length > 0) {
if (rawRule.oneOf) {
Expand Down

0 comments on commit 7238a44

Please sign in to comment.