Skip to content

Commit 680b39e

Browse files
committed
fix: add and test support for CSS modules composes
1 parent 644c448 commit 680b39e

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"lodash.camelcase": "^4.3.0",
5555
"postcss": "^8.4.21",
5656
"postcss-load-config": "^3.1.4",
57+
"postcss-modules-extract-imports": "^3.0.0",
5758
"postcss-modules-local-by-default": "^4.0.0",
5859
"postcss-modules-scope": "^3.0.0",
5960
"reserved-words": "^0.1.2",
@@ -68,6 +69,7 @@
6869
"@types/less": "^3.0.3",
6970
"@types/lodash.camelcase": "^4.3.7",
7071
"@types/node": "^18.14.0",
72+
"@types/postcss-modules-extract-imports": "^3.0.2",
7173
"@types/reserved-words": "^0.1.0",
7274
"@types/sass": "^1.43.1",
7375
"@types/stylus": "^0.48.38",

pnpm-lock.yaml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.className {
2+
width: 100%;
3+
}

src/helpers/__tests__/fixtures/test.module.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,12 @@
3434
opacity: 1;
3535
}
3636
}
37+
38+
.composed {
39+
composes: classA;
40+
display: block;
41+
}
42+
43+
.composed-from-other-file {
44+
composes: className from './_composed.css';
45+
}

src/helpers/getProcessor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import postcss, { AcceptedPlugin } from 'postcss';
22
import Processor from 'postcss/lib/processor';
33
import postcssLocalByDefault from 'postcss-modules-local-by-default';
44
import postcssModulesScope from 'postcss-modules-scope';
5+
import postcssModulesExtractImports from 'postcss-modules-extract-imports';
56

67
export const getProcessor = (
78
additionalPlugins: AcceptedPlugin[] = [],
89
): Processor =>
910
postcss([
1011
...additionalPlugins,
1112
postcssLocalByDefault(),
13+
postcssModulesExtractImports(),
1214
postcssModulesScope({
1315
generateScopedName: (name) => name,
1416
}),

0 commit comments

Comments
 (0)