-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Access asset URL from CSS import #1757
Comments
If you want to bundle the imported CSS file, you can write a plugin that invokes esbuild recursively to bundle the CSS file and then return the bundled CSS from the plugin so it can be imported. Plugin documentation is here: https://esbuild.github.io/plugins/#load-callbacks. |
Thanks for the response Evan Would this produce any asset conflicts if one or more build instances share the same output directory? |
@lxsmnsyc I don't know if this will answer your question. With esbuild I am bundling from multiple CSS root files (files with css imports) and the output directory is the same for all of them, I just need to change the output file name. |
@vcaballero-salle Thanks for the response. However, it doesn't fit what I currently need right now and is counter-intuitive on how I load the CSS. The reason I wanted to acquire the URL is so that I know which CSS file to load for at that part of code. |
You can use |
Neat! I didn't know that! Thank you |
Is there any way to do something like this? (at least in plugins?)
Using
"file"
loader would definitely work for providing the asset URL however it skips the bundling process and thus causes a lot of fallthroughs (e.g. at-rule imports, fonts, images, etc.). I wanted to access the asset URL while bundling the imported CSS file.The text was updated successfully, but these errors were encountered: