Skip to content

Commit 54501b4

Browse files
committed
exclude eslint-loader from selector requests
1 parent 71f7df8 commit 54501b4

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/loader.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,28 @@ var defaultLang = {
3434
script: 'js'
3535
}
3636

37+
// When extracting parts from the source vue file, we want to apply the
38+
// 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) {
44+
const clonedContext = Object.assign({}, context, {
45+
loaders: context.loaders.filter(loader => !excludedPreLoadersRE.test(loader.path))
46+
})
47+
delete clonedContext.remainingRequest
48+
return loaderUtils.getRemainingRequest(clonedContext)
49+
}
50+
3751
module.exports = function (content) {
3852
this.cacheable()
3953
var isServer = this.options.target === 'node'
4054
var isProduction = this.minimize || process.env.NODE_ENV === 'production'
4155

4256
var loaderContext = this
4357
var query = loaderUtils.parseQuery(this.query)
58+
var rawRequest = getRawRequest(this)
4459
var options = this.options.__vueOptions__ = Object.assign({}, this.options.vue, this.vue, query)
4560

4661
var filePath = this.resourcePath
@@ -85,7 +100,7 @@ module.exports = function (content) {
85100
// select the corresponding part from the vue file
86101
getSelectorString(type, index || 0) +
87102
// the url to the actual vue file, including remaining requests
88-
loaderUtils.getRemainingRequest(loaderContext)
103+
rawRequest
89104
)
90105
}
91106

0 commit comments

Comments
 (0)