-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Duplicate stylesheet injection in production build #5834
Comments
I think this issue and #5715 might be related |
@nicholasray yes it likely is. I'm planning on taking a look soon. |
Adding a +1 to this bug, I'm seeing link and script tags injected twice on pages using one of the layouts. Thanks! What version of astro are you using?1.9.0 Are you using an SSR adapter? If so, which one?No What package manager are you using?npm What operating system are you using?Mac Describe the BugStylesheet and script tags are being injected into the body with one layout but not both. The layout it's happening to is PageLayout.astro in my repo. Link to Minimal Reproducible Examplehttps://astro-docs-prototype.netlify.app/ |
Thanks for the repro! I'll be working on this soon. |
I had this issue with nested layouts so I reverted back to a unique layout for now. Now I have the same issue in a component with a so it looks like the imported js and css are duplicated as soon as we use a (in a layout or in a component). Duplication occurs in dev and in prod. Edit: My component is a Svelte component so it's not limited to Astro layouts or components. |
I have a fix for this, just working out some details to avoid breaking some corner case layouts. Should have this in a patch next week. |
No more duplicate script/link tags for me, but on one of my layouts (the opposite this time) it's injecting them into the body. Can see that behavior on this page: https://astro-docs-prototype.netlify.app/docs/en/tutorial/a-tutorial/ I updated to 2.0.4 and this time it's my ArticleLayout.astro pages (so, flipped from my original comment above). |
fwiw, I also experienced the flash of unstyled content with 2.0.4. I reverted back to 2.0.2 as a result |
I'm only see the tags injected into the body on pages that have MDX components, so it looks like it may have more to do with the MDX integration than layouts at this point. I'll check for any other filed issues and create a new one if need be. |
Thanks, ping me if you file a new issue. |
@matthewp Hi, thank you for the attention on this. I added my details here: #6057 (comment) |
i experienced duplicate css injections & flash of unstyled content i remove @astrojs/prefetch and it's resolved |
What version of
astro
are you using?1.9.1
Are you using an SSR adapter? If so, which one?
No
What package manager are you using?
npm
What operating system are you using?
Mac, Linux
Describe the Bug
When using a layout which extends another layout, CSS stylesheets get injected twice in the production build of the site. This occurs on any page using the extended layout.
The first injection occurs in the
<head>
of the page.The second injection occurs at the beginning of the
<body>
of the page.Thank you so much for your attention to this issue! If you need any further information let me know.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-2ugymh-oqddw9
UPDATE (1/19/23): We've found that this also extends to
injectScript
as well, so built a second example to account for that too. Hopefully this is useful to you!https://stackblitz.com/edit/github-2ugymh-e6stgx
Participation
The text was updated successfully, but these errors were encountered: