added light/dark mode toggle v1, unified menu
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
# Portable Django + Vite integration
|
||||
|
||||
This repository did not previously contain Vite configuration, package scripts, a manifest, or Vite-aware Django templates. Its only asset setup was Django native static files. The files below add an isolated, reusable Vite integration without attaching any Vite bundle to existing pages.
|
||||
This repository originally used only Django native static files. The Vite integration below is now wired into the rendered public pages and custom Admin pages: shared assets live in `frontend/src/`, while Django still owns template rendering and its native static files.
|
||||
|
||||
## What is included
|
||||
|
||||
- `vite_integration/`: reusable Django app and `{% vite_asset %}` tag
|
||||
- `frontend/src/main.js`: replaceable example entry point
|
||||
- `frontend/src/entries/`: one Vite entry module per rendered page, with shared `styles/` and `scripts/` modules
|
||||
- `vite.config.mjs`: Vite output, manifest, host, port, and entry configuration
|
||||
- `package.json`: `dev`, `django`, `vite`, and `build` scripts
|
||||
- `scripts/dev-django.mjs`: configurable backend process for `concurrently`
|
||||
@@ -36,7 +36,7 @@ Choose an entry point and include it once in the relevant base template:
|
||||
|
||||
```django
|
||||
{% load vite %}
|
||||
{% vite_asset "frontend/src/main.js" %}
|
||||
{% vite_asset "frontend/src/entries/site.js" %}
|
||||
```
|
||||
|
||||
The tag renders Vite's HMR client and the entry point when `VITE_USE_DEV_SERVER=true`. Otherwise it reads Vite's manifest and renders the fingerprinted CSS and JavaScript under Django's static URL. See `vite_integration/templates/vite_integration/example_assets.html` for the same snippet.
|
||||
@@ -64,7 +64,7 @@ package.json
|
||||
.env.vite.example
|
||||
```
|
||||
|
||||
Then add `vite_integration` to `INSTALLED_APPS`, add the template tag to a base template, configure `STATIC_URL`/`STATIC_ROOT`, install npm packages, and use the development or production commands above. The integration contains no application names, routes, or backend URLs.
|
||||
Create `frontend/src/entries/site.js` (or another entry beneath `VITE_ENTRY_DIR`) that imports the page CSS and JavaScript. Then add `vite_integration` to `INSTALLED_APPS`, add the template tag to a base template, configure `STATIC_URL`/`STATIC_ROOT`, install npm packages, and use the development or production commands above. The integration contains no application names, routes, or backend URLs.
|
||||
|
||||
## Configuration values to customize
|
||||
|
||||
@@ -74,8 +74,10 @@ Then add `vite_integration` to `INSTALLED_APPS`, add the template tag to a base
|
||||
| `DJANGO_HOST`, `DJANGO_PORT` | `127.0.0.1`, `8000` | Default backend bind address |
|
||||
| `VITE_HOST`, `VITE_PORT` | `127.0.0.1`, `5173` | Vite bind address and port |
|
||||
| `VITE_DEV_SERVER_URL` | `http://127.0.0.1:5173/` | URL Django templates use for HMR |
|
||||
| `VITE_DEV_BASE_URL` | `/` | Development-only Vite base path |
|
||||
| `VITE_USE_DEV_SERVER` | `false` | Enables HMR tags; set only for development |
|
||||
| `VITE_ENTRY` | `frontend/src/main.js` | Vite Rollup entry point |
|
||||
| `VITE_ENTRY_DIR` | `frontend/src/entries` | Directory Vite scans for page entry points |
|
||||
| `VITE_ENTRY` | unset | Optional comma-separated explicit entry point list |
|
||||
| `VITE_OUT_DIR` | `vite_integration/static/vite` | Build output relative to project root |
|
||||
| `VITE_STATIC_PREFIX` | `vite` | Django static namespace for built files |
|
||||
| `VITE_BASE_URL` | `/static/vite/` | Public base URL emitted by Vite |
|
||||
|
||||
Reference in New Issue
Block a user