Skip to content

Commit a0b5e2b

Browse files
committed
fix: Don't use rules that also match ".html"
This adds a check so that rules that match foo.vue.html but *also* foo.html are ignored. Resolves vuejs#1625
1 parent b53ae44 commit a0b5e2b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Diff for: lib/plugin-webpack4.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ class VueLoaderPlugin {
3131
// find the rule that applies to vue files
3232
let vueRuleIndex = rawRules.findIndex(createMatcher(`foo.vue`))
3333
if (vueRuleIndex < 0) {
34-
vueRuleIndex = rawRules.findIndex(createMatcher(`foo.vue.html`))
34+
const vueHtmlRuleIndex = rawRules.findIndex(createMatcher(`foo.vue.html`))
35+
const htmlOnlyRuleIndex = rawRules.findIndex(createMatcher(`foo.html`))
36+
// Only use the .vue.html rules if they don't also match normal .html files
37+
if (vueHtmlRuleIndex >= 0 && htmlOnlyRuleIndex < 0) {
38+
vueRuleIndex = vueHtmlRuleIndex
39+
}
3540
}
3641
const vueRule = rules[vueRuleIndex]
3742

Diff for: lib/plugin-webpack5.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,16 @@ class VueLoaderPlugin {
6060
})
6161

6262
if (!vueRules.length) {
63-
vueRules = ruleSet.exec({
63+
const vueHtmlRules = ruleSet.exec({
6464
resource: 'foo.vue.html'
6565
})
66+
const htmlOnlyRules = ruleSet.exec({
67+
resource: 'foo.html'
68+
})
69+
// Only use the .vue.html rules if they don't also match normal .html files
70+
if (vueHtmlRules.length > htmlOnlyRules.length) {
71+
vueRules = vueHtmlRules
72+
}
6673
}
6774
if (vueRules.length > 0) {
6875
if (rawRule.oneOf) {

0 commit comments

Comments
 (0)