File tree 2 files changed +27
-1
lines changed
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ const isNullLoader = l => /(\/|\\|@)null-loader/.test(l.path)
10
10
const isCSSLoader = l => / ( \/ | \\ | @ ) c s s - l o a d e r / . test ( l . path )
11
11
const isCacheLoader = l => / ( \/ | \\ | @ ) c a c h e - l o a d e r / . test ( l . path )
12
12
const isPitcher = l => l . path !== __filename
13
+ const isPreLoader = l => ! l . pitchExecuted
14
+ const isPostLoader = l => l . pitchExecuted
13
15
14
16
const dedupeESLintLoader = loaders => {
15
17
const res = [ ]
@@ -136,10 +138,15 @@ module.exports.pitch = function (remainingRequest) {
136
138
cacheIdentifier : hash ( cacheIdentifier ) + '-vue-loader-template'
137
139
} ) } `]
138
140
: [ ]
141
+
142
+ const preLoaders = loaders . filter ( isPreLoader )
143
+ const postLoaders = loaders . filter ( isPostLoader )
144
+
139
145
const request = genRequest ( [
140
146
...cacheLoader ,
147
+ ...postLoaders ,
141
148
templateLoaderPath + `??vue-loader-options` ,
142
- ...loaders
149
+ ...preLoaders
143
150
] )
144
151
// console.log(request)
145
152
// the template compiler uses esm exports
Original file line number Diff line number Diff line change @@ -305,3 +305,22 @@ test('disable prettify', done => {
305
305
done ( )
306
306
} )
307
307
} )
308
+
309
+ test ( 'postLoaders support' , done => {
310
+ mockBundleAndRun ( {
311
+ entry : 'basic.vue' ,
312
+ module : {
313
+ rules : [
314
+ {
315
+ resourceQuery : / ^ \? v u e & t y p e = t e m p l a t e / ,
316
+ enforce : 'post' ,
317
+ loader : path . resolve ( __dirname , './mock-loaders/html' )
318
+ }
319
+ ]
320
+ }
321
+ } , ( { module } ) => {
322
+ // class="red" -> { staticClass: "red" } -> { staticClass: "green" }
323
+ expect ( module . render . toString ( ) ) . toMatch ( `green` )
324
+ done ( )
325
+ } )
326
+ } )
You can’t perform that action at this time.
0 commit comments