You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,10 @@ A [PostCSS](https://postcss.org/) plugin for type safe [CSS modules](https://git
6
6
7
7
This plugin takes CSS modules one step further by generating `.js` and `.d.ts` files for each CSS module file. This means that CSS class names imported from a CSS module file will be typechecked so that developers can't reference non-existent classes. Source maps are also generated so that you can navigate from a CSS module class name directly to the Sass file.
8
8
9
-
For example, if you have the following CSS module file:
9
+
For example, if you have the following SCSS module file:
10
10
11
11
```css
12
-
// header.module.css
12
+
// header.module.scss
13
13
.header {
14
14
font-size: 1.5rem;
15
15
}
@@ -19,7 +19,7 @@ In your corresponding TypeScript file, the following would work:
@@ -30,7 +30,7 @@ However, referencing a non-existent class will fail to compile:
30
30
31
31
```tsx
32
32
importReactfrom"react";
33
-
import*ascssfrom"./header.module.css";
33
+
import*ascssfrom"./header.module.scss";
34
34
35
35
exportconst Header:React.FC= () => {
36
36
// Will fail to compile
@@ -78,15 +78,17 @@ module.exports = {
78
78
};
79
79
```
80
80
81
-
For each CSS module file, the following files will get written to disk in the output directory (`--dir` if using the [postcss-cli](https://github.com/postcss/postcss-cli)):
81
+
For each SCSS module file, the following files will get written to disk in the output directory (`--dir` if using the [postcss-cli](https://github.com/postcss/postcss-cli)):
82
82
83
83
```
84
84
# In this example, build/postcss is the output directory for PostCSS
85
85
src/
86
86
hello.module.scss
87
+
hello.tsx # Contains the import for header.module.scss
87
88
build/
88
89
postcss/
89
-
hello.module.scss.js
90
+
_hello.module.css # Compiled CSS that is imported by hello.module.scss.js
91
+
hello.module.scss.js # File actually imported by hello.tsx
0 commit comments