diff --git a/docs/en/configurations/advanced.md b/docs/en/configurations/advanced.md index 5c48d64cf..17aa63da7 100644 --- a/docs/en/configurations/advanced.md +++ b/docs/en/configurations/advanced.md @@ -48,7 +48,10 @@ module.exports = { // plugin will be a better option. postLoaders: { html: 'babel-loader' - } + }, + + // `excludedPreLoaders` should be regex + excludedPreLoaders: /(eslint-loader)/ } } ] diff --git a/lib/loader.js b/lib/loader.js index 7778a3858..40db2985e 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -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)) }) } @@ -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)