From 11201f4882d5b0ca32a326dee238f1ded72f8817 Mon Sep 17 00:00:00 2001 From: Victor Zakharenko Date: Thu, 3 Nov 2016 16:24:26 +0300 Subject: [PATCH 1/2] computed hash classNames at front and back sides --- lib/loader.js | 73 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 11 deletions(-) diff --git a/lib/loader.js b/lib/loader.js index f2a61c005..c60c28f1b 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -77,7 +77,7 @@ module.exports = function (content) { // disable all configuration loaders '!!' + // get loader string for pre-processors - getLoaderString(type, part, scoped) + + getLoaderString(type, part, index, scoped) + // select the corresponding part from the vue file getSelectorString(type, index || 0) + // the url to the actual vuefile @@ -94,17 +94,41 @@ module.exports = function (content) { function getRequireForImportString (type, impt, scoped) { return loaderUtils.stringifyRequest(loaderContext, '!!' + - getLoaderString(type, impt, scoped) + + getLoaderString(type, impt, -1, scoped) + impt.src ) } - function getLoaderString (type, part, scoped) { + function addCssModulesToLoader (loader, part, index) { + if (!part.module) return loader + return loader.replace(/((?:^|!)css(?:-loader)?)(\?[^!]*)?/, function (m, $1, $2) { + // $1: !css-loader + // $2: ?a=b + var query = loaderUtils.parseQuery($2) + query.modules = true + query.importLoaders = true + query.localIdentName = query.localIdentName || '[hash:base64:7]' + if (index !== -1) { + // Note: + // Class name is generated according to its filename. + // Different