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
+34-10Lines changed: 34 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ for [CSS Modules](https://github.com/css-modules/css-modules).
12
12
This project was inspired by this [`create-react-app` issue](https://github.com/facebook/create-react-app/issues/5677)
13
13
and was based on [`css-module-types`](https://github.com/timothykang/css-module-types).
14
14
15
-
## Usage
15
+
## Installation
16
16
17
17
To install with Yarn:
18
18
@@ -36,12 +36,32 @@ Once installed, add this plugin to your `tsconfig.json`:
36
36
}
37
37
```
38
38
39
+
### Importing CSS
40
+
41
+
A default export is always provided for your CSS module.
42
+
43
+
```tsx
44
+
importstylesfrom'my.module.css';
45
+
46
+
const a =styles.myClass;
47
+
const b =styles['my_other-class'];
48
+
```
49
+
50
+
As of version 1.1.0, you can also use named exports for classes that don't contain hyphens or underscores. You can still access other classes via the default export.
|`customMatcher`|`"\\.module\\.(sa\|sc\|c)ss$"`| Change the file extensions that this plugin works with. |
44
-
|`camelCase`|`false`| Implements the behaviour of the [`camelCase` CSS Loader option](https://github.com/webpack-contrib/css-loader#camelcase) (accepting the same values). |
|`customMatcher`|`"\\.module\\.(c\|le\|sa\|sc)ss$"`| Change the file extensions that this plugin works with. |
64
+
|`camelCase`|`false`| Implements the behaviour of the [`camelCase` CSS Loader option](https://github.com/webpack-contrib/css-loader#camelcase) (accepting the same values). |
45
65
46
66
The below is an example that only matches "\*.m.css" files, and [camel-cases dashes](https://github.com/webpack-contrib/css-loader#camelcase).
47
67
@@ -65,17 +85,16 @@ The below is an example that only matches "\*.m.css" files, and [camel-cases das
65
85
66
86
By default, VSCode will use it's own version of TypeScript. To make it work with this plugin, you have two options:
67
87
68
-
1. Add this plugin to `"typescript.tsserver.pluginPaths"` in settings. Note that this method doesn't currently support
69
-
plugin options. This is planned for the [November update](https://github.com/Microsoft/vscode/issues/62876).
88
+
1. Use your workspace's version of TypeScript, which will load plugins from your `tsconfig.json` file. This is the recommended approach. For instructions, see: [Using the workspace version of TypeScript](https://code.visualstudio.com/docs/languages/typescript#_using-the-workspace-version-of-typescript).
89
+
90
+
2. Add this plugin to `"typescript.tsserver.pluginPaths"` in settings. Note that this method doesn't currently support plugin options.
2. Use your workspace's version of TypeScript, which will load the plugins from your `tsconfig.json` file. For instructions, see: [Using the workspace version of TypeScript](https://code.visualstudio.com/docs/languages/typescript#_using-the-workspace-version-of-typescript).
78
-
79
98
### Custom definitions
80
99
81
100
_Note: Create React App users can skip this section if you're using `[email protected]` or higher._
@@ -84,7 +103,7 @@ If your project doesn't already have global declarations for CSS Modules, you wi
84
103
85
104
Where you store global declarations is up to you. An example might look like: `src/custom.d.ts`.
86
105
87
-
The below is an example that you can copy, or modify if you use a `customMatcher`.
106
+
The below is an example that you can copy or modify. If you use a `customMatcher`, you'll need to modify it.
0 commit comments