Skip to content

Commit e2b41ea

Browse files
committed
feat: support chaining with other loaders for pre-processing (close #542)
1 parent 07b9452 commit e2b41ea

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

lib/loader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ module.exports = function (content) {
7777
getLoaderString(type, part, index, scoped) +
7878
// select the corresponding part from the vue file
7979
getSelectorString(type, index || 0) +
80-
// the url to the actual vuefile
81-
filePath
80+
// the url to the actual vue file, including remaining requests
81+
loaderUtils.getRemainingRequest(loaderContext)
8282
)
8383
}
8484

test/mock-loader.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = function (content) {
2+
return content.replace(/Hello from Component A!/, 'Changed!')
3+
}

test/test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,4 +497,19 @@ describe('vue-loader', function () {
497497
done()
498498
})
499499
})
500+
501+
it('support chaining with other loaders', done => {
502+
const mockLoaderPath = require.resolve('./mock-loader')
503+
test({
504+
entry: './test/fixtures/basic.vue',
505+
module: {
506+
rules: [
507+
{ test: /\.vue$/, loader: loaderPath + '!' + mockLoaderPath }
508+
]
509+
}
510+
}, function (window, module) {
511+
expect(module.data().msg).to.equal('Changed!')
512+
done()
513+
})
514+
})
500515
})

0 commit comments

Comments
 (0)