activeguild / vite-plugin-sass-dts

This is a plugin that automatically creates a type file when using the CSS module type-safely.
MIT License
116 stars 18 forks source link

Wrong path to global common style types from deeper directory #64

Closed iPapatsoris closed 1 year ago

iPapatsoris commented 1 year ago

Hello, thanks for the great plugin.

I'm not sure if there is something I have configured wrong myself, but if I enter the example directory of this repo and create a file /src/User/User.module.scss, then the generated /src/User/User.module.scss.d.ts starts with the following line: import globalClassNames, { ClassNames as GlobalClassNames } from '..style.d' which doesn't work correctly, because the import path should be '../style.d'.

activeguild commented 1 year ago

@iPapatsoris

Should be fixed in with!

"vite-plugin-sass-dts": "^1.2.9"

Thanks for the issue!!

mkholt commented 8 months ago

I am seeing this exact problem in version 1.3.16, has it re-appeared, or am I doing something wrong?

I have: /assets/styles/_index.scss /pages/index/main.module.scss

vite.config.ts specifies:

plugins: [react({}), ssr({}), sassDts({
    enabledMode: ['development', 'production'],
    global: {
      generate: true,
      outputFilePath: path.resolve(__dirname, "./@types/style.d.ts"),
    },
  })]

A file main.module.scss.d.ts is generated:

import globalClassNames from "....@types/style.d";
declare const classNames: typeof globalClassNames & {
  readonly hero: "hero";
  readonly headerImage: "headerImage";
};
export = classNames;

Note that ....@types/style.d should be `../../@types/style.d´