Created
September 24, 2017 03:39
-
-
Save Kcin1993/682fd216defbb7822e6f3cd9865ad6f6 to your computer and use it in GitHub Desktop.
Typescript-css-moduler-setting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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