-
Notifications
You must be signed in to change notification settings - Fork 18
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
Classes in the common stylesheet are duplicated for every component #95
Comments
Hi. This may be achieved by combining the additinalData and global options.
vite-plugin-sass-dts/example/react-sass/vite.config.ts Lines 37 to 40 in ff0f07b
|
I already have these options enabled (I haven't changed anything from the original |
I think we can achieve confirmation by doing the following. |
Thanks, it works great! One small downside that I noticed, is that if we switch the index.css file to index.scss (and update the import in main.tsx), then in the final production stylesheet we get the following:
I'm not sure how to get rid of the |
I didn't understand the problem.
|
The problem is that after building for production, we see a compiled CSS file with the following code
whereas we only need
It's not a real problem, but more of an unnecessary rule that I was wondering how to get rid of. The |
Hi,
In the example
react-sass
, I notice that for the common styles file (src/assets/styles/_index.scss
), a different css module class is generated for every component that imports styles. For example, 2 different css module classes are generated for the.row
class, because there are 2 files that import styles (App.tsx
andUser.tsx
). This happens even if we don't directly use the.row
class withinUser.tsx
. In a larger project, it means that all the classes within the common stylesheet will be duplicated for every component that uses styles, even though we only need 1 instance of each common class.Is it possible to generate only 1 class for
.row
, and reuse the same one across different files, while maintaining type safety? Or is there some other workaround to get the desired behavior?Thanks!
The text was updated successfully, but these errors were encountered: