File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 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)
1010const isCSSLoader = l => / ( \/ | \\ | @ ) c s s - l o a d e r / . test ( l . path )
1111const isCacheLoader = l => / ( \/ | \\ | @ ) c a c h e - l o a d e r / . test ( l . path )
1212const isPitcher = l => l . path !== __filename
13+ const isPreLoader = l => ! l . pitchExecuted
14+ const isPostLoader = l => l . pitchExecuted
1315
1416const dedupeESLintLoader = loaders => {
1517 const res = [ ]
@@ -136,10 +138,15 @@ module.exports.pitch = function (remainingRequest) {
136138 cacheIdentifier : hash ( cacheIdentifier ) + '-vue-loader-template'
137139 } ) } `]
138140 : [ ]
141+
142+ const preLoaders = loaders . filter ( isPreLoader )
143+ const postLoaders = loaders . filter ( isPostLoader )
144+
139145 const request = genRequest ( [
140146 ...cacheLoader ,
147+ ...postLoaders ,
141148 templateLoaderPath + `??vue-loader-options` ,
142- ...loaders
149+ ...preLoaders
143150 ] )
144151 // console.log(request)
145152 // the template compiler uses esm exports
Original file line number Diff line number Diff line change @@ -305,3 +305,22 @@ test('disable prettify', done => {
305305 done ( )
306306 } )
307307} )
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