Commit 2be55078 authored by Evan You's avatar Evan You

fix: handle vue rule with include (fix #1201)

parent d3642e26
...@@ -11,7 +11,11 @@ module.exports = class VueLoaderPlugin { ...@@ -11,7 +11,11 @@ module.exports = class VueLoaderPlugin {
// find the rule that applies to vue files // find the rule that applies to vue files
const vueRuleIndex = rawRules.findIndex((rule, i) => { const vueRuleIndex = rawRules.findIndex((rule, i) => {
return !rule.enforce && rawNormalizedRules[i].resource(`foo.vue`) // #1201 we need to skip the `include` check when locating the vue rule
const clone = Object.assign({}, rule)
delete clone.include
const normalized = RuleSet.normalizeRule(clone)
return !rule.enforce && normalized.resource(`foo.vue`)
}) })
const vueRule = rawRules[vueRuleIndex] const vueRule = rawRules[vueRuleIndex]
......
const {
mockRender,
mockBundleAndRun
} = require('./utils')
const normalizeNewline = require('normalize-newline')
test('vue rule with include', done => {
mockBundleAndRun({
entry: 'basic.vue',
modify: config => {
config.module.rules[0] = {
test: /\.vue$/,
include: /fixtures/,
loader: 'vue-loader'
}
}
}, ({ window, module, rawModule }) => {
const vnode = mockRender(module, {
msg: 'hi'
})
// <h2 class="red">{{msg}}</h2>
expect(vnode.tag).toBe('h2')
expect(vnode.data.staticClass).toBe('red')
expect(vnode.children[0].text).toBe('hi')
expect(module.data().msg).toContain('Hello from Component A!')
let style = window.document.querySelector('style').textContent
style = normalizeNewline(style)
expect(style).toContain('comp-a h2 {\n color: #f00;\n}')
done()
})
})
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