-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
CSS full path for images #1539
Comments
Not for sure for this, can you give a reproduction?
This is a bad idea. It will increase file size and the output only can be published at one endpoint. |
only for the dev environment. The build work like a charm since image path end up being relative to the CSS.
I'll create a small repo to showcase the problem if you want. |
There are relevant test cases passing: https://github.com/vitejs/vite/blob/main/packages/playground/assets/css/css-url.css#L2 So yeah a reproduction is needed. |
Here is the repository (as simple as I could) to illustrate my use case and my problem. https://github.com/Grafikart/demo-error-vite The problem comes when the CSS is injected in the page on a completely different host since
This code will look for For context, I'm trying to include vite workflow with some backend applications (laravel / symfony / wordpress...). |
That's expected. You need to make your main server to also serve static files in the Vite directory. This is not something Vite will handle. |
I just got bitten by this problem too, i know this is by design but it might be a difficult problem to solve on hybrid scenarios where you have a web app like laravel or symfony working with vite... In my use case i have a laravel project and the static files that are breaking are the font files from font awesome, and the problem is that now it's hitting my web server for the files, like: The problem is that the file structure of a laravel project is:
And the web server serve directly to the I know i can make adjustments to my nginx / web server changing root and to serve anything starting with node_modules to that folder and everything else to the usual If an option could be introduced to make use of Vite dev server for CSS Static files would make it easy to be used for a lot of more users. ❤️ |
Agreed. Just had the same issue with a Symfony project. Pretty sure it will be the same with any php CMS as well. |
@dbpolito FYI this is also an issue with snowpack hmr. |
I've noticed the opposite problem. I have imported a component/style framework that uses an icon font via a rule like this: @font-face {
font-family: 'rsuite-icon-font';
src: url('https://cdn.jsdelivr.net/npm/rsuite/dist/styles/fonts/rsuite-icon-font.ttf') format('truetype'), url('https://cdn.jsdelivr.net/npm/rsuite/dist/styles/fonts/rsuite-icon-font.woff') format('woff');
font-weight: normal;
font-style: normal;
} When compiled those absolute urls become:
It seems the code is blindly just prepending whatever is in those |
in vite.config.js use config of
|
This issue has been locked since it has been closed for more than 14 days. If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion. |
Describe the bug
When vite is required (included from another endpoint) the reference to images in the CSS are lost cause the CSS is injected in the page.
When transpiled I think it would be nice to inject the full path to avoid any problem
Or maybe offer a configuration to set the "publicPath"
Reproduction
Start any vite template including CSS. Then load this from another endpoint.
For instance I'm on http://localhost:8000 and I include
System Info
vite
version: 2.0.0-beta.27The text was updated successfully, but these errors were encountered: