Skip to content

[feature]About the hard-coded list of excluded loaders chained before vue-loader #697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/en/configurations/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ module.exports = {
// plugin will be a better option.
postLoaders: {
html: 'babel-loader'
}
},

// `excludedPreLoaders` should be regex
excludedPreLoaders: /(eslint-loader)/
}
}
]
Expand Down
12 changes: 5 additions & 7 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ var defaultLang = {

// When extracting parts from the source vue file, we want to apply the
// loaders chained before vue-loader, but exclude some loaders that simply
// produces side effects such as linting. This is a hard-coded list and
// hopefully eslint-loader is the only one.
var excludedPreLoadersRE = /eslint-loader/

function getRawRequest (context) {
// produces side effects such as linting.
function getRawRequest (context, excludedPreLoaders) {
excludedPreLoaders = excludedPreLoaders || /eslint-loader/
return loaderUtils.getRemainingRequest({
resource: context.resource,
loaderIndex: context.loaderIndex,
loaders: context.loaders.filter(loader => !excludedPreLoadersRE.test(loader.path))
loaders: context.loaders.filter(loader => !excludedPreLoaders.test(loader.path))
})
}

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

var loaderContext = this
var query = loaderUtils.getOptions(this) || {}
var rawRequest = getRawRequest(this)
var options = this.options.__vueOptions__ = Object.assign({}, this.options.vue, this.vue, query)
var rawRequest = getRawRequest(this, options.excludedPreLoaders)

var filePath = this.resourcePath
var fileName = path.basename(filePath)
Expand Down