-
Notifications
You must be signed in to change notification settings - Fork 73
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
Load Assets' Images #7
Comments
Thanks ! It's possible, you need to import them into you I keep your issue open, and if other peoples are demanding of this feature I will give it a look, or if you want to do a PR and implement it, you're welcome. |
It would be great if the |
I got stuck with this for a little while. Just a note for anyone looking to import images and use them elsewhere within their javascript frontend: As per Vite docs https://vitejs.dev/guide/assets.html you can just:
They won't work with django-vite in dev mode right away, because it'll be hitting the django dev server using a relative path, rather than your vite dev server. To fix, just add the following option to your vite config:
That way, you'll get absolute generated asset URLs during development |
Another way of achieving this is to use a copy plugin (such as https://www.npmjs.com/package/rollup-plugin-copy) to copy any assets you need in Django during your Vite build process - then when Django grabs your This is useful if the assets themselves aren't bundled by Vite. |
@aresti this should be documented :) faced the same issue |
@azabraao |
Hi, I'm sorry for the disappointment. I initially created I see that this problem occurs very often so please make a PR that I will be happy to merge as you will explain, document and give answers to the problem better than me. ✌️ |
Thanks for this really helpful library.
Is there a possibility to load the static images that are inside the
static
folder ? Like Django's{% static %}
.For example:
When I visit an image using
{% static %}
it shows 404 error.But when I change the port to 3000 it shows that
django-vite
imported it.The text was updated successfully, but these errors were encountered: