Skip to content

Commit

Permalink
fix: unable to generate correct class names for Less modules
Browse files Browse the repository at this point in the history
revert: fb3034d
  • Loading branch information
AnYiEE committed Feb 19, 2024
1 parent 7dce70b commit 6c2070d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions scripts/modules/build-esbuild_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const esbuildOptions = {
plugins: [
CssModulesPlugin({
targets,
filter: /\.module\.(?:css|less)$/i,
namedExports: true,
}),
postcss(),
lessLoader({
Expand Down
9 changes: 9 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
*/
declare module '*.css';
declare module '*.less';
declare module '*.module.css' {
const classes: {[key: string]: string};
export default classes;
}

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

/**
* @summary Do not forget to declare these file extensions in `scripts/build-esbuild_options.ts`
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
"name": "typescript-plugin-css-modules",
"options": {
"classnameTransform": "camelCaseOnly",
"goToDefinition": true,
"namedExports": false
"goToDefinition": true
}
}
],
Expand Down

0 comments on commit 6c2070d

Please sign in to comment.