✨Feature: Vite HMR in development mode + Vite backend django integration #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes hackforla#563
Changes
Big changes:
django-vite
package in the backend: https://github.com/MrBin99/django-vitedocker-compose.dev.yml
file for quickly booting up the dev environment on your local machine.docker-compose.yml
file to be honest. It wasn't working for me.dev/vite.Dockerfile
and adev/django.dockerfile
for building separate containers for the frontend and backed.django.dockerfile
:Try it yourself
How to run the new full stack CivicTechJobs application in development mode?
http://localhost:8000
in your browserfrontend/src/pages/LandingPage/LandingPageIntro.tsx
How does the new vite backend integration work?
Vite dev server
$ vite dev
inside the/frontend
directory will start a vite development server with fast Hot Module Reload enabled.settings.py
file is configured to load js modules from the dev server inDEBUG
mode (aka dev mode).django-vite
PyPI package.django-vite
is set to fill in yourindex.html
template with vite js modules for you.Production bundle
$ vite build
inside the/frontend
directory will create a build directly in the django backend.backend/vite_assets_dist
.Changes by file:
./.dockerignore
- added the production build and tidied up a bit./.gitignore
- ignore the vite static assets buildbackend/settings.py
- configured environment variables and set up django-vite integrationbackend/urls.py
- add a path for the newindex.html
templatebackend/poetry.lock
- addeddjango-vite
andpython-decouple
packagesbackend/pyproject.toml
- addeddjango-vite
andpython-decouple
packagesbackend/templates/index.html
- moved the index.html template from the frontend to the django backend, where it makes more sense to keep.dev/django.Dockerfile
- new dockerfile for building the django dev environment docker imagedev/vite.Dockerfile
- new dockerfile for building the vite development server docker image./docker-compose.dev.yml
- new compose file for running the application in development modefrontend/.gitignore
- ignorevite.config.mts.timestamp...
- this temp file is created when you run$ vite dev
, but sometimes it does not get removed after.frontend/package.json
- removevite-plugin-html
package, it is no longer neededfrontend/package-lock.json
- removevite-plugin-html
package, it is no longer neededfrontend/src/index.tsx
- importvite/modulepreload-polyfill
- necessary for vite backend integration.frontend/src/templates/vite-index.html
- removed this file as it is no longer neededfrontend/vite.config.mts
- configured vite settings to integrate with django backend and docker compose.Screenshots, if applicable
No changes to the website's appearance.