From aaaf070d484906b3805022782a007456a30cdac8 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Sun, 4 Jun 2017 21:52:05 +0200 Subject: [PATCH 1/3] Add support for postcss-nested plugin --- package.json | 3 ++- src/requireCssModule.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 15bbd17..5f5fb17 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "postcss-modules-local-by-default": "^1.1.1", "postcss-modules-parser": "^1.1.0", "postcss-modules-scope": "^1.0.2", - "postcss-modules-values": "^1.2.2" + "postcss-modules-values": "^1.2.2", + "postcss-nested": "^2.0.2" }, "description": "Transforms styleName to className using compile time CSS module resolution.", "devDependencies": { diff --git a/src/requireCssModule.js b/src/requireCssModule.js index 28e8703..b7ea0b7 100644 --- a/src/requireCssModule.js +++ b/src/requireCssModule.js @@ -11,6 +11,7 @@ import postcss from 'postcss'; import genericNames from 'generic-names'; import ExtractImports from 'postcss-modules-extract-imports'; import LocalByDefault from 'postcss-modules-local-by-default'; +import Nested from 'postcss-nested'; import Parser from 'postcss-modules-parser'; import Scope from 'postcss-modules-scope'; import Values from 'postcss-modules-values'; @@ -66,6 +67,7 @@ export default (cssSourceFilePath: string, options: OptionsType): StyleModuleMap }; const plugins = [ + Nested, Values, LocalByDefault, ExtractImports, From 32a661a1914ec4545d27d500634015ec3f490f05 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Mon, 5 Jun 2017 09:53:05 +0200 Subject: [PATCH 2/3] Changed version of postcss-nested to 1.0.1 to support postcss 5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5f5fb17..365c87d 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "postcss-modules-parser": "^1.1.0", "postcss-modules-scope": "^1.0.2", "postcss-modules-values": "^1.2.2", - "postcss-nested": "^2.0.2" + "postcss-nested": "^1.0.1" }, "description": "Transforms styleName to className using compile time CSS module resolution.", "devDependencies": { From b8ebb48b14095c64cfaff0b85d6f1a8c04f12dbb Mon Sep 17 00:00:00 2001 From: Mikhail Date: Mon, 5 Jun 2017 09:54:09 +0200 Subject: [PATCH 3/3] Added a test for postcss-nested --- .../actual.js | 3 +++ .../bar.scss | 6 ++++++ .../expected.js | 3 +++ .../options.json | 13 +++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 test/fixtures/react-css-modules/resolves styleName from nested class in scss/actual.js create mode 100644 test/fixtures/react-css-modules/resolves styleName from nested class in scss/bar.scss create mode 100644 test/fixtures/react-css-modules/resolves styleName from nested class in scss/expected.js create mode 100644 test/fixtures/react-css-modules/resolves styleName from nested class in scss/options.json diff --git a/test/fixtures/react-css-modules/resolves styleName from nested class in scss/actual.js b/test/fixtures/react-css-modules/resolves styleName from nested class in scss/actual.js new file mode 100644 index 0000000..b4ccea8 --- /dev/null +++ b/test/fixtures/react-css-modules/resolves styleName from nested class in scss/actual.js @@ -0,0 +1,3 @@ +import './bar.scss'; + +
; diff --git a/test/fixtures/react-css-modules/resolves styleName from nested class in scss/bar.scss b/test/fixtures/react-css-modules/resolves styleName from nested class in scss/bar.scss new file mode 100644 index 0000000..71fe056 --- /dev/null +++ b/test/fixtures/react-css-modules/resolves styleName from nested class in scss/bar.scss @@ -0,0 +1,6 @@ +.a { + background-color: #ffffff; + &_modified { + background-color: #000000; + } +} \ No newline at end of file diff --git a/test/fixtures/react-css-modules/resolves styleName from nested class in scss/expected.js b/test/fixtures/react-css-modules/resolves styleName from nested class in scss/expected.js new file mode 100644 index 0000000..417f11d --- /dev/null +++ b/test/fixtures/react-css-modules/resolves styleName from nested class in scss/expected.js @@ -0,0 +1,3 @@ +import './bar.scss'; + +
; diff --git a/test/fixtures/react-css-modules/resolves styleName from nested class in scss/options.json b/test/fixtures/react-css-modules/resolves styleName from nested class in scss/options.json new file mode 100644 index 0000000..9e9fa1f --- /dev/null +++ b/test/fixtures/react-css-modules/resolves styleName from nested class in scss/options.json @@ -0,0 +1,13 @@ +{ + "plugins": [ + [ + "../../../../src", + { + "generateScopedName": "[name]__[local]", + "filetypes": { + ".scss": "postcss-scss" + } + } + ] + ] +}