From 715eaa1ac001a37739ece3b0f828f9a92e7fc56a Mon Sep 17 00:00:00 2001 From: nicholaslee119 Date: Wed, 8 Mar 2017 08:14:25 +0900 Subject: [PATCH 1/3] make excluded preloader configurable --- lib/loader.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/loader.js b/lib/loader.js index 7778a3858..fa8d24492 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -38,13 +38,12 @@ var defaultLang = { // 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) { +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 +54,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) From 337419781e044c2678f228560d66b7d609f1cda6 Mon Sep 17 00:00:00 2001 From: nicholaslee119 Date: Wed, 8 Mar 2017 08:16:24 +0900 Subject: [PATCH 2/3] fix the comment --- lib/loader.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/loader.js b/lib/loader.js index fa8d24492..40db2985e 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -36,8 +36,7 @@ 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. +// produces side effects such as linting. function getRawRequest (context, excludedPreLoaders) { excludedPreLoaders = excludedPreLoaders || /eslint-loader/ return loaderUtils.getRemainingRequest({ From fb9ffb3fc1f45e44a2b47556d8390ebb02b220ff Mon Sep 17 00:00:00 2001 From: nicholaslee119 Date: Wed, 8 Mar 2017 08:22:15 +0900 Subject: [PATCH 3/3] update the document --- docs/en/configurations/advanced.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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)/ } } ]