Skip to content

Instantly share code, notes, and snippets.

@Kcin1993
Created September 24, 2017 03:39
Show Gist options
  • Save Kcin1993/682fd216defbb7822e6f3cd9865ad6f6 to your computer and use it in GitHub Desktop.
Save Kcin1993/682fd216defbb7822e6f3cd9865ad6f6 to your computer and use it in GitHub Desktop.
Typescript-css-moduler-setting
1. install this package
```
yarn add https://github.com/Quramy/typed-css-modules -D
```
2. In webpack
```
{
test: /\.css$/,
use: [
{ loader: 'style-loader'},
{
loader: 'css-loader',
query: {
modules: true,
localIdentName: '[path][name]__[local]--[hash:base64:5]'
}
}
]
}
```
3. Run following to generate the cssFileName.css.d.ts (Note. need to install typed-css-modules global)
```
tcm src --watch
```
4. Using in component
```
import * as styles from './component.css'
<div className={styles.exampleClass}></div>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment