Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger declaration generation in vite build watch mode when non-ts file changes #335

Open
2 tasks done
jtiala opened this issue May 28, 2024 · 2 comments
Open
2 tasks done
Labels
enhancement New feature or request

Comments

@jtiala
Copy link

jtiala commented May 28, 2024

Description

At the moment, when Vite build watch mode is enabled, declarations get generated only when typescript files are modiefied.
I think the declarations should be generated on every change or we should be able to specify which file types trigger the generation.

My use case is that I have a library that has React components and CSS files. When I'm using the watch mode and modify a typescript file, everything works as expected. But when I modify a CSS file, vite triggers a build, which by default empties the out dir first getting rid of the declarations.

Using emptyOutDir would be a way around this, but it has other problems. And even if it worked as its supposed to work, it might have other side effects in different kinds of configurations.

Suggested solution

I'm suggesting that in watch mode, the declarations would get generated on every builld, not just when typescript files changes.

Alternative

Alternatively (or in addition), a config option for file extensions (or globs) that trigger the generation would be a viable solution.

Additional context

No response

Validations

  • Read the FAQ.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@qmhc
Copy link
Owner

qmhc commented Aug 21, 2024

Would you try to using the include option to include those CSS files and test whether it works?

@qmhc qmhc added the pending Need further confirmation label Aug 21, 2024
@jtiala
Copy link
Author

jtiala commented Aug 21, 2024

Including .css files doesn't seem to change anything. This is my config now, it still behaves like described in the issue.

dts({
      insertTypesEntry: true,
      rollupTypes: true,
      exclude: ["**/*.stories.tsx"],
      include: ["**/*.ts", "**/*.tsx", "**/*.css"],
}),

@qmhc qmhc added enhancement New feature or request and removed pending Need further confirmation labels Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants