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

All pages styles are being bundled and delivered #26987

Open
kasadawa opened this issue Apr 29, 2024 · 3 comments
Open

All pages styles are being bundled and delivered #26987

kasadawa opened this issue Apr 29, 2024 · 3 comments

Comments

@kasadawa
Copy link

Environment

Nuxt: 3.11
Bundler: vite
Css Preprocessor: less

Reproduction

Createa a brand new project, 2 layouts, several pages*.server.vue. All of the layouts / pages should have styles inside. After building the project, going to a single layout -> page, all of the styles of all pages /layouts are being delivered.

Describe the bug

Using Nuxt 3 SSR mode, with all pages being .server.vue deliveres by default inline styles only.

This issue is whenever we add:

vite: { build: { cssCodeSplit: false, }, }
With this config and .server.vue, there is a single styles.css file delivered, which contains all of the styles withing pages/ pages*.server.vue.
I also have /layouts folder, it also combines all of the styles from the layouts.

So the styles.css file, contain a lot of unused and conflicting styles. Before, with nuxt 2/ webpack I didn't have those issues at all. I was using inline styles and only the needed ones were delivered.

There is also an issue with the inlined-styles on the child components, which are using typescript. #25923

Additional context

No response

Logs

No response

Copy link
Contributor

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritize it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz
👉 https://codesandbox.io/s/github/nuxt/starter/v3-codesandbox

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@huang-julien
Copy link
Member

https://vitejs.dev/config/build-options#build-csscodesplit Setting css code split to false force vite to not split css by chunk and merge thel into a single css file.

@kasadawa
Copy link
Author

Hey @huang-julien ,
Thanks for answering. I'm fully aware of that. Its merging everything , no matter if its used or not / or being called or not. The root or the problem is that it combines all of the styles, insead of needed ones. I suppose that it cannot re-generate styles based on route. As well due to using *.server.vue its duplicating the styles - 1 time they are added as inline and one time as styles.css file.

The default behavour should be for each component / page there should be a style file , but in case of using .server.vue on pages, it just inlines the styles into the html. I wouldn't mind on going with that, but I saw other side effect with it, which I linked above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants