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
+21-17Lines changed: 21 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,17 @@ A toolkit for making CSS Modules useful.
6
6
7
7
By default, CSS Modules have limited language features in editors. For example:
8
8
9
-
- Clicking on `styles.button` does not jump to its definition in `Button.module.css`.
10
-
-When renaming `styles.button`, the corresponding `.button {...}` in `Button.module.css` is not renamed.
11
-
-Performing "Find All References" on`styles.button` does not find its definition in `Button.module.css`.
9
+
- Clicking on `styles.button` does not go to its definition in `Button.module.css`.
10
+
-Renaming `styles.button` does not rename the corresponding `.button {...}` in `Button.module.css`.
11
+
- Find all references of`styles.button` does not include its definition in `Button.module.css`.
12
12
13
-
It has been difficult to solve these issues because the TypeScript Language Server (tsserver) does not handle CSS files. Since tsserver does not hold information about CSS files, it cannot calculate jump destinations or determine which code should be renamed.
13
+
It has been difficult to solve these issues because the TypeScript Language Server (tsserver) does not handle CSS files. Since tsserver does not load CSS files, it cannot determine which definitions to go to or which code to rename.
14
14
15
-
css-modules-kit addresses this by using a TypeScript Language Service Plugin. With this plugin, css-modules-kit extends tsserver to handle `*.module.css` files. As a result, many language features like code navigation and rename refactoring become available.
15
+
css-modules-kit solves this problem by using the [TypeScript Language Service Plugin](https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin). With this plugin, css-modules-kit extends tsserver to handle `*.module.css` files. As a result, rich language features like code navigation and rename refactoring become available.
16
16
17
-
Additionally, css-modules-kit provides various development tools for CSS Modules, such as a stylelint plugin and a utility for generating `*.d.ts` files.
17
+
Another method that provides rich language features is to use the VS Code Extension API (see: https://github.com/Viijay-Kr/react-ts-css). However, it only supports VS Code. On the other hand, css-modules-kit is based on the TypeScript Language Service Plugin, so it supports other editors as well.
18
+
19
+
Additionally, css-modules-kit provides various development tools for CSS Modules. For example, stylelint plugins and the tool that generates `*.d.ts` files.
<summary>Create CSS Module file for current file.</summary>
61
+
<summary>Create CSS Module file for current file</summary>
60
62
61
63
If there is no CSS Module file corresponding to `xxx.tsx`, create one.
62
64
@@ -194,13 +196,21 @@ When this option is `true`, `import { button } from '...'` will be added. When t
194
196
}
195
197
```
196
198
199
+
## Supported CSS Modules features
200
+
201
+
-`:local(...)` and `:global(...)`
202
+
-`@keyframes <name> { ... }`
203
+
-`@value <name>: <value>;`
204
+
-`@value <name>[, <value>]+ from <module-specifier>;`
205
+
-`@import <module-specifier>;`
206
+
197
207
## Limitations
198
208
199
209
To simplify the implementation, some features are not supported.
200
210
201
-
- Sass/Less are not supported.
202
-
- If you want to use Sass/Less, please use [happy-css-modules](https://github.com/mizdra/happy-css-modules). Although it does not offer as rich language features as css-modules-kit, it provides basic features such as code completion and Go to Definition.
203
-
- The name of classes, @value, and @keyframes must be valid JavaScript identifiers.
211
+
- Sass and Less are not supported.
212
+
- If you want to use Sass and Less, please use [happy-css-modules](https://github.com/mizdra/happy-css-modules). Although it does not offer as rich language features as css-modules-kit, it provides basic features such as code completion and Go to Definition.
213
+
- The name of classes, `@value`, and `@keyframes` must be valid JavaScript identifiers.
204
214
- For example, `.fooBar` and `.foo_bar` are supported, but `.foo-bar` is not supported.
205
215
- See [#176](https://github.com/mizdra/css-modules-kit/issues/176) for more details.
206
216
-`:local .foo {...}` is not supported.
@@ -210,10 +220,4 @@ To simplify the implementation, some features are not supported.
210
220
-`@keyframes :local(foo) {...}` is not supported.
211
221
- Use `@keyframes foo {...}` instead.
212
222
- Meanwhile, `@keyframes :global(foo) { ... }` is supported.
213
-
- css-modules-kit does not work on VS Code for Web.
214
-
215
-
## History of this project
216
-
217
-
This project was created as a next-generation tool to replace [happy-css-modules](https://github.com/mizdra/happy-css-modules).
218
-
219
-
happy-css-modules was also a tool that provided language functionality for `*.module.css`. However, the tool was limited in the type of language features it could provide. To solve this limitation, css-modules-kit was created.
0 commit comments