Skip to content

Commit

Permalink
Merge pull request #21 from roydukkey/issue/20
Browse files Browse the repository at this point in the history
Add TypeScript support for Sass/SCSS modules
  • Loading branch information
rlamana committed Jul 20, 2023
2 parents 7a5720c + 2fe9818 commit 70e42fc
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 @@ -78,7 +78,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.4",
"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 70e42fc

Please sign in to comment.