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

Error: Unable to preload CSS when using import.meta.glob #8329

Closed
1 task done
lilnasy opened this issue Aug 31, 2023 · 2 comments · Fixed by #8351
Closed
1 task done

Error: Unable to preload CSS when using import.meta.glob #8329

lilnasy opened this issue Aug 31, 2023 · 2 comments · Fixed by #8351
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: styling Related to styles (scope)

Comments

@lilnasy
Copy link
Contributor

lilnasy commented Aug 31, 2023

Astro info

Astro version            v3.0.3
Package manager          npm
Platform                 linux
Architecture             x64
Adapter                  Couldn't determine.
Integrations             auto-import, @astrojs/tailwind, @astrojs/svelte, @astrojs/mdx, @astrojs/preact

What browser are you using?

Chrome

Describe the Bug

image

There is supposed to be a rendered image in that box.

For some reason, vite attains references to css chunks and tries to manually load them using javascript. Some of these stylesheets were inlined and removed from the bundle. The css loads as expected but javascript code added by vite throws, which prevents user code from executing.

image

Editing the vite code to not throw is sufficient to prevent this, but hopefully there's a better angle.

What's the expected result?

image

Link to Minimal Reproducible Example

https://github.com/threlte/threlte/tree/1dfc901/apps/docs

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 31, 2023
@lilnasy lilnasy added feat: styling Related to styles (scope) - P3: minor bug An edge case that only affects very specific usage (priority) and removed needs triage Issue needs to be triaged labels Aug 31, 2023
@lilnasy lilnasy changed the title Inlined stylesheets are referenced by vite's preload helper Error: Unable to preload CSS when using import.meta.glob Sep 1, 2023
@Matb85
Copy link

Matb85 commented Sep 4, 2023

Hi, I've encountered a similar issue
In dev mode everything works fine but after building, astro throws 404 errors while trying to dynamically import a svelte component with CSS.
Screenshot 2023-09-04 at 23 02 14
Screenshot 2023-09-04 at 23 03 41

Any ideas on how to solve this?

@lilnasy
Copy link
Contributor Author

lilnasy commented Sep 5, 2023

Hi, @Matb85. Sorry you're running into this issue. I opened a PR for a fix, but for now you can set build.inlineStylesheets: "never" in your config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: styling Related to styles (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants