Skip to content

Commit 2048f51

Browse files
committed
values and symbols added
1 parent 20f946e commit 2048f51

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
"dependencies": {
1010
"debug": "^2.2.0",
11+
"icss-replace-symbols": "^1.0.2",
1112
"lodash.assign": "^3.2.0",
1213
"lodash.identity": "^3.0.0",
1314
"lodash.isarray": "^3.0.4",
@@ -18,7 +19,7 @@
1819
"devDependencies": {
1920
"babel": "^5.8.20",
2021
"babel-eslint": "^4.0.5",
21-
"css-modules-loader-core": "0.0.12",
22+
"css-modules-loader-core": "^1.0.0",
2223
"eslint": "^1.0.0",
2324
"eslint-config-airbnb": "0.0.7",
2425
"eslint-config-airbnb-lite": "^1.0.3",
@@ -31,13 +32,15 @@
3132
"postcss-modules-extract-imports": "^1.0.0",
3233
"postcss-modules-local-by-default": "^1.0.0",
3334
"postcss-modules-scope": "^1.0.0",
35+
"postcss-modules-values": "^1.1.0",
3436
"precommit-hook": "^3.0.0"
3537
},
3638
"peerDependencies": {
3739
"postcss": "^5.x",
3840
"postcss-modules-extract-imports": "^1.0.0",
3941
"postcss-modules-local-by-default": "^1.0.0",
40-
"postcss-modules-scope": "^1.0.0"
42+
"postcss-modules-scope": "^1.0.0",
43+
"postcss-modules-values": "^1.1.0"
4144
},
4245
"scripts": {
4346
"start": "esw -w .",

src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import identity from 'lodash.identity';
88
import pick from 'lodash.pick';
99
import postcss from 'postcss';
1010

11+
import Values from 'postcss-modules-values';
1112
import ExtractImports from 'postcss-modules-extract-imports';
1213
import LocalByDefault from 'postcss-modules-local-by-default';
1314
import Scope from 'postcss-modules-scope';
@@ -71,6 +72,7 @@ export default function setup(opts = {}) {
7172

7273
plugins = [
7374
...prepend,
75+
Values,
7476
mode
7577
? new LocalByDefault({mode: opts.mode})
7678
: LocalByDefault,

src/parser.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { plugin } from 'postcss';
2+
import replaceSymbols from 'icss-replace-symbols';
23

34
const importRegexp = /^:import\((.+)\)$/;
45

@@ -30,11 +31,7 @@ export default plugin('parser', function parser(opts = {}) {
3031
});
3132
};
3233

33-
const linkImportedSymbols = css => css.eachDecl(decl => {
34-
Object.keys(translations).forEach(translation => {
35-
decl.value = decl.value.replace(translation, translations[translation]);
36-
});
37-
});
34+
const linkImportedSymbols = css => replaceSymbols(css, translations);
3835

3936
const handleExport = exportNode => {
4037
exportNode.each(decl => {

0 commit comments

Comments
 (0)