File tree 2 files changed +39
-1
lines changed
2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,11 @@ module.exports = class VueLoaderPlugin {
11
11
12
12
// find the rule that applies to vue files
13
13
const vueRuleIndex = rawRules . findIndex ( ( rule , i ) => {
14
- return ! rule . enforce && rawNormalizedRules [ i ] . resource ( `foo.vue` )
14
+ // #1201 we need to skip the `include` check when locating the vue rule
15
+ const clone = Object . assign ( { } , rule )
16
+ delete clone . include
17
+ const normalized = RuleSet . normalizeRule ( clone )
18
+ return ! rule . enforce && normalized . resource ( `foo.vue` )
15
19
} )
16
20
const vueRule = rawRules [ vueRuleIndex ]
17
21
Original file line number Diff line number Diff line change
1
+ const {
2
+ mockRender,
3
+ mockBundleAndRun
4
+ } = require ( './utils' )
5
+
6
+ const normalizeNewline = require ( 'normalize-newline' )
7
+
8
+ test ( 'vue rule with include' , done => {
9
+ mockBundleAndRun ( {
10
+ entry : 'basic.vue' ,
11
+ modify : config => {
12
+ config . module . rules [ 0 ] = {
13
+ test : / \. v u e $ / ,
14
+ include : / f i x t u r e s / ,
15
+ loader : 'vue-loader'
16
+ }
17
+ }
18
+ } , ( { window, module, rawModule } ) => {
19
+ const vnode = mockRender ( module , {
20
+ msg : 'hi'
21
+ } )
22
+
23
+ // <h2 class="red">{{msg}}</h2>
24
+ expect ( vnode . tag ) . toBe ( 'h2' )
25
+ expect ( vnode . data . staticClass ) . toBe ( 'red' )
26
+ expect ( vnode . children [ 0 ] . text ) . toBe ( 'hi' )
27
+
28
+ expect ( module . data ( ) . msg ) . toContain ( 'Hello from Component A!' )
29
+ let style = window . document . querySelector ( 'style' ) . textContent
30
+ style = normalizeNewline ( style )
31
+ expect ( style ) . toContain ( 'comp-a h2 {\n color: #f00;\n}' )
32
+ done ( )
33
+ } )
34
+ } )
You can’t perform that action at this time.
0 commit comments