-
Notifications
You must be signed in to change notification settings - Fork 34
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
Nested imports' CSS aren't processed when the dev server isn't running #98
Comments
I've been able to mitigate this on my multi-entrypoint project using vite-plugin-css-injected-by-js with the relativeCSSInjection flag set to true. Injects the css into the dom on a per-chunk basis, and as a bonus I don't have to import each entrypoint as a stylesheet. |
Hi, do you have a reproduction repo? |
Hello, |
I'm also interrested by this feature |
Yes, please |
Here it is https://github.com/hdimon/ViteAspNetCoreTest/tree/multiple_css_files . |
Ran into this yesterday. Seems more like a pretty important enhancement to me, given that it effectively isn't implementing the specification. Any reasonably sized project will probably result in several css files and thus they won't end up getting pulled in (probably?). I might be interested in fixing it, but I need your input. I wrote my own <vite-styles entry-point="path/to/my/file.ts" /> Edit: on the other hand, I guess it could be a pretty big breaking change to change the tag helper, so my Idea is probably dumb. Let me know what you think |
We also parse the manifest ourselves, and build a dictionary of chunk names and chunks. We also have a tag helper that accepts the name of an entry point, then calls a method on the class that holds the parsed manifest to retrieve all css files for that entry point. An issue we ran into though, was when loading async chunks after the entry point was loaded (while navigating client side for instance). Where the chunk also depended on the shared css, it seems the bundled js added a new link tag with the shared css (now 2 of the same). That messed up some styling for us, but I see in the spec link someguy20336 added that they add the entry point css first then the shared css. I guess it ends up working in most cases anyway, but in case someone else have a similar issue we fixed it by using css layers. |
Hi @hdimon. Thanks for the reproduction repo. Try again with the new v2.1 release. It should work now, so I'm closing the issue. |
Hi @someguy20336. As you said, changing the tag helper syntax is a pretty big breaking change, so that's not an option. But if you have a better implementation, you can try to improve the current implementation and open a pull request. |
Is your feature request related to a problem? Please describe.
Nested CSS assets aren't loaded, for instance a component imports a .scss which has
@use '@mdi/font'
, icons are not displayed.This works fine when in dev mode, but fails with a prod build due to nesting in the manifest.
Describe the solution you'd like
ProcessCssEntry.Process
should processentry.Imports
recursively.Describe alternatives you've considered
.
Additional context
There is a todo regarding multiple css entries, so this would potentially address this too.
Here's a snippet of manifest; note
main.ts
has animports
reference, that in turn has acss
asset:Maybe a bit like this? (the tag writing could be better)
The text was updated successfully, but these errors were encountered: