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

Vite preview support #48

Open
joshua-farmlink opened this issue Jun 29, 2022 · 1 comment
Open

Vite preview support #48

joshua-farmlink opened this issue Jun 29, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@joshua-farmlink
Copy link

joshua-farmlink commented Jun 29, 2022

Hi, I'm wondering if it's possible to support something like vite preview and/or vite build --watch?

I guess the current expectation for checking prod builds is that you would call vite build then collect static and set DJANGO_VITE_DEV_MODE=False before starting the django dev server? Since Vite has the preview command I thought it might be nice to make use of it.

When I tried vite preview, however, the django-vite {% vite_asset 'main.js' %} template tag still served the https://127.0.0.1:3000/static/main.js file instead of something like http://127.0.0.1:3000/static/main.a7ab852f.js which is determined based on the manifest.json file. Of course, the {% vite_hmr_client %} tag also tried to load the HMR client because it's still in dev mode, so maybe this would require an additional config option like DJANGO_VITE_PREVIEW_MODE or something.

Even better would be if we could use vite build --watch and vite preview in combination. The first would create your initial bundle, plus update the build when you make changes, then with vite preview running, if you refreshed the page, it would get the updated bundle files from the preview server. This way you wouldn't have to wait for a complete build to happen each time, call collectstatic, etc. You just save your changes and refresh the page.

@MrBin99
Copy link
Owner

MrBin99 commented Aug 21, 2022

I will take a look if this is possible.

@MrBin99 MrBin99 added the enhancement New feature or request label Aug 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants