Skip to content

Commit 0aa8a6e

Browse files
JounQinyyx990803
authored andcommitted
use to merge cssModules configuration with (vuejs#446)
1 parent c120c0f commit 0aa8a6e

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ npm-debug.log
33
test/output
44
docs/_book
55
.DS_Store
6+
.idea
7+
*.iml

lib/loader.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,18 @@ module.exports = function (content) {
102102
function addCssModulesToLoader (loader, part, index) {
103103
if (!part.module) return loader
104104
var option = options.cssModules || {}
105+
var DEFAULT_OPTIONS = {
106+
modules: true,
107+
importLoaders: true
108+
}
109+
var OPTIONS = {
110+
localIdentName: '[hash:base64]'
111+
}
105112
return loader.replace(/((?:^|!)css(?:-loader)?)(\?[^!]*)?/, function (m, $1, $2) {
106113
// $1: !css-loader
107114
// $2: ?a=b
108115
var query = loaderUtils.parseQuery($2)
109-
query.modules = true
110-
query.importLoaders = true
111-
query.localIdentName = option.localIdentName || '[hash:base64]'
116+
Object.assign(query, OPTIONS, option, DEFAULT_OPTIONS)
112117
if (index !== -1) {
113118
// Note:
114119
// Class name is generated according to its filename.

test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ describe('vue-loader', function () {
383383
test({
384384
entry: './test/fixtures/css-modules.vue',
385385
vue: {
386-
cssModules: {
386+
cssModules: localIdentName && {
387387
localIdentName: localIdentName
388388
}
389389
}

0 commit comments

Comments
 (0)