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

Build breaks when importing CSS as inline #6145

Closed
1 task
santicros opened this issue Feb 6, 2023 · 2 comments · Fixed by #6161
Closed
1 task

Build breaks when importing CSS as inline #6145

santicros opened this issue Feb 6, 2023 · 2 comments · Fixed by #6161
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@santicros
Copy link

santicros commented Feb 6, 2023

What version of astro are you using?

2.0.6

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

MacOS 12.6

Describe the Bug

When trying to import a CSS file inline, it works on development, but it breaks on build.

Vite supports importing CSS inline with the ?inline param: https://vitejs.dev/guide/features.html#disabling-css-injection-into-the-page like this:

import otherStyles from './bar.css?inline' // will not be injected into the page

When doing this on Astro, it works in development mode, but when doing build it breaks, saying:

 Cannot find module '/home/projects/github-5xrgxx/dist/chunks/index.83f085fc.2f5bdb15.mjs' imported from /home/projects/github-5xrgxx/dist/chunks/pages/all.c4bb7b53.mjs

I personally need this to share some styles to a canvas and embed them inline. I need to import a stylesheet as text and use it inside JavaScript. Thanks!

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-5xrgxx?file=src/pages/index.astro

Participation

  • I am willing to submit a pull request for this issue.
@matthewp
Copy link
Contributor

matthewp commented Feb 6, 2023

I ran into this as well so I'm biased in favor of fixing. :-D

@matthewp matthewp self-assigned this Feb 6, 2023
@matthewp matthewp added the - P3: minor bug An edge case that only affects very specific usage (priority) label Feb 6, 2023
@matthewp
Copy link
Contributor

matthewp commented Feb 6, 2023

Pretty sure this is a Vite bug, css @bluwy. Looks like it's deleting the chunk because it's "pure". But this should not be treated as pure.

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)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants