vite-plugin-sass-dts icon indicating copy to clipboard operation
vite-plugin-sass-dts copied to clipboard

Only generate types in CI?

Open aakagi opened this issue 1 year ago • 4 comments

Is there a way to generate the type definitions only in CI?

I would prefer to .gitignore the files locally and re-generate them in CI. Is this possible to do?

aakagi avatar Mar 07 '24 16:03 aakagi

@aakagi What kind of use do you want to make of it?

activeguild avatar Mar 11 '24 05:03 activeguild

  1. I would like to have the *.scss.d.ts files generated locally, for local type-safety while developing.
  2. I do not want to have to commit the file changes to git. I would like to add *.scss.d.ts to my .gitignore.
  3. I want to run a command in my github actions CI script to generate these types because I do not want the build to succeed if there are any typescript errors.

It would be nice to be able to run a command like this to check type safety:

# Generate types
yarn vite-plugin-sass-dts # [--args]

# Check type safety
yarn tsc

Is it easy to add a command like this?

aakagi avatar Mar 11 '24 14:03 aakagi

Understood, I'll see what I can do.

activeguild avatar Mar 12 '24 01:03 activeguild

@aakagi

I'll need a configuration file for execution in cli, but I'm not sure.

activeguild avatar Mar 18 '24 00:03 activeguild

I figured out a solution that works!

I wrote a script that checks to make sure each .module.scss file has a sibling .module.scss.d.ts file, and throws an error if it doesn't, or if a "rogue" one is found.

The script I wrote also allows you to pass in a --fix flag which updates the file timestamp for .module.scss files that are missing a sibling .module.scss.d.ts file, which then causes vite-plugin-sass-dts to generate the file 😄. The --fix flag will also delete any "rogue" .module.scss.d.ts files that are found.

You can read through the full implementation here: https://gist.github.com/aakagi/d0c9954b1ec617b9b6ab150d7d78a892

aakagi avatar Sep 19 '24 01:09 aakagi