Skip to content

Commit

Permalink
Add TypeScript support for Sass/SCSS modules
Browse files Browse the repository at this point in the history
  • Loading branch information
roydukkey committed Oct 6, 2021
1 parent f38017f commit c482d9a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,16 @@ function MyComponent() {
}
```

### TypeScript support

To enable TypeScript support for Sass/SCSS modules, the TypeScript configuration should be updated to add the `docusaurus-plugin-sass` type definitions. This can be done in the `tsconfig.json` file:



```diff
{
"extends": "@tsconfig/docusaurus/tsconfig.json",
"compilerOptions": {
...
+ "types": ["docusaurus-plugin-sass"]
}
}
```
19 changes: 19 additions & 0 deletions docusaurus-plugin-sass.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
declare module '*.module.scss' {
const classes: { readonly [key: string]: string };
export default classes;
}

declare module '*.module.sass' {
const classes: { readonly [key: string]: string };
export default classes;
}

declare module '*.scss' {
const src: string;
export default src;
}

declare module '*.sass' {
const src: string;
export default src;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.2.1",
"description": "Docusaurus plugin to provide support for SASS/SCSS",
"main": "docusaurus-plugin-sass.js",
"types": "docusaurus-plugin-sass.d.ts",
"dependencies": {
"sass-loader": "^10.1.1"
},
Expand Down

0 comments on commit c482d9a

Please sign in to comment.