Skip to content

Commit bded451

Browse files
nicholaslee119yyx990803
authored andcommitted
[feature]About the hard-coded list of excluded loaders chained before vue-loader (#697)
* make excluded preloader configurable * fix the comment * update the document
1 parent bfacd61 commit bded451

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

docs/en/configurations/advanced.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ module.exports = {
4848
// plugin will be a better option.
4949
postLoaders: {
5050
html: 'babel-loader'
51-
}
51+
},
52+
53+
// `excludedPreLoaders` should be regex
54+
excludedPreLoaders: /(eslint-loader)/
5255
}
5356
}
5457
]

lib/loader.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@ var defaultLang = {
3636

3737
// When extracting parts from the source vue file, we want to apply the
3838
// loaders chained before vue-loader, but exclude some loaders that simply
39-
// produces side effects such as linting. This is a hard-coded list and
40-
// hopefully eslint-loader is the only one.
41-
var excludedPreLoadersRE = /eslint-loader/
42-
43-
function getRawRequest (context) {
39+
// produces side effects such as linting.
40+
function getRawRequest (context, excludedPreLoaders) {
41+
excludedPreLoaders = excludedPreLoaders || /eslint-loader/
4442
return loaderUtils.getRemainingRequest({
4543
resource: context.resource,
4644
loaderIndex: context.loaderIndex,
47-
loaders: context.loaders.filter(loader => !excludedPreLoadersRE.test(loader.path))
45+
loaders: context.loaders.filter(loader => !excludedPreLoaders.test(loader.path))
4846
})
4947
}
5048

@@ -55,8 +53,8 @@ module.exports = function (content) {
5553

5654
var loaderContext = this
5755
var query = loaderUtils.getOptions(this) || {}
58-
var rawRequest = getRawRequest(this)
5956
var options = this.options.__vueOptions__ = Object.assign({}, this.options.vue, this.vue, query)
57+
var rawRequest = getRawRequest(this, options.excludedPreLoaders)
6058

6159
var filePath = this.resourcePath
6260
var fileName = path.basename(filePath)

0 commit comments

Comments
 (0)