diff --git a/README.md b/README.md index 9fe7ed4..48bde76 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ Compiling in runtime, [universal](https://medium.com/@mjackson/universal-javascr To use this tool we require [Node.js v0.12.x](https://github.com/nodejs/node) (or higher) and several modules to be installed. -- [postcss](https://github.com/postcss/postcss) version 4 or higher +- [postcss](https://github.com/postcss/postcss) version 5 or higher +- [postcss-modules-values](https://github.com/css-modules/postcss-modules-values) - [postcss-modules-extract-imports](https://github.com/css-modules/postcss-modules-extract-imports) - [postcss-modules-local-by-default](https://github.com/css-modules/postcss-modules-local-by-default) - [postcss-modules-scope](https://github.com/css-modules/postcss-modules-scope) diff --git a/package.json b/package.json index 8392e2d..e2535f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "css-modules-require-hook", - "version": "1.0.11", + "version": "2.0.0-beta", "description": "A require hook to compile CSS Modules on the fly", "main": "index.js", "engines": { @@ -8,6 +8,7 @@ }, "dependencies": { "debug": "^2.2.0", + "icss-replace-symbols": "^1.0.2", "lodash.assign": "^3.2.0", "lodash.identity": "^3.0.0", "lodash.isarray": "^3.0.4", @@ -18,7 +19,7 @@ "devDependencies": { "babel": "^5.8.20", "babel-eslint": "^4.0.5", - "css-modules-loader-core": "0.0.12", + "css-modules-loader-core": "^1.0.0", "eslint": "^1.0.0", "eslint-config-airbnb": "0.0.7", "eslint-config-airbnb-lite": "^1.0.3", @@ -27,17 +28,19 @@ "isparta": "^3.0.3", "lodash": "^3.10.1", "mocha": "^2.2.5", - "postcss": "5.x", - "postcss-modules-extract-imports": "^1.0.0-beta", - "postcss-modules-local-by-default": "^1.0.0-beta", - "postcss-modules-scope": "^1.0.0-beta", + "postcss": "^5.x", + "postcss-modules-extract-imports": "^1.0.0", + "postcss-modules-local-by-default": "^1.0.0", + "postcss-modules-scope": "^1.0.0", + "postcss-modules-values": "^1.1.0", "precommit-hook": "^3.0.0" }, "peerDependencies": { - "postcss": ">=4.x", - "postcss-modules-extract-imports": ">=0.x || ^1.0.0-beta", - "postcss-modules-local-by-default": ">=0.x || ^1.0.0-beta", - "postcss-modules-scope": ">=0.x || ^1.0.0-beta" + "postcss": "^5.x", + "postcss-modules-extract-imports": "^1.0.0", + "postcss-modules-local-by-default": "^1.0.0", + "postcss-modules-scope": "^1.0.0", + "postcss-modules-values": "^1.1.0" }, "scripts": { "start": "esw -w .", diff --git a/src/index.js b/src/index.js index 55dee04..a34dc5a 100644 --- a/src/index.js +++ b/src/index.js @@ -8,6 +8,7 @@ import identity from 'lodash.identity'; import pick from 'lodash.pick'; import postcss from 'postcss'; +import Values from 'postcss-modules-values'; import ExtractImports from 'postcss-modules-extract-imports'; import LocalByDefault from 'postcss-modules-local-by-default'; import Scope from 'postcss-modules-scope'; @@ -71,6 +72,7 @@ export default function setup(opts = {}) { plugins = [ ...prepend, + Values, mode ? new LocalByDefault({mode: opts.mode}) : LocalByDefault, diff --git a/src/parser.js b/src/parser.js index 84c6cdf..15c47e9 100644 --- a/src/parser.js +++ b/src/parser.js @@ -1,4 +1,5 @@ import { plugin } from 'postcss'; +import replaceSymbols from 'icss-replace-symbols'; const importRegexp = /^:import\((.+)\)$/; @@ -30,11 +31,7 @@ export default plugin('parser', function parser(opts = {}) { }); }; - const linkImportedSymbols = css => css.eachDecl(decl => { - Object.keys(translations).forEach(translation => { - decl.value = decl.value.replace(translation, translations[translation]); - }); - }); + const linkImportedSymbols = css => replaceSymbols(css, translations); const handleExport = exportNode => { exportNode.each(decl => {