I am unable to import scss file in below format.
import * as styles from './index.scss';
getting below error
:
can not find module './index.scss'
I want to use class name like below :
className={styles.anyClassName}
Introduction: We can use SASS in React using a package called node-sass. Using node-sass we can just create sass files and use them as the normal CSS files in our React application and node-sass will take care of compiling sass files.
In order to import SCSS as object in TS like this :
import * as styles from './index.scss';
declare module '*.scss' {
const content: {[className: string]: string};
export = content;
}
https://basarat.gitbooks.io/typescript/docs/types/ambient/d.ts.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With