# Tasknest frontend This directory owns browser assets. Vite compiles `src/main.js`, its SCSS import, and the local `htmx.org` dependency. Django renders those assets through the `{% vite_asset 'src/main.js' %}` template tag in `planner/base.html`. ## First-time setup Install Node.js 20.19+ (or a newer current LTS), then run: ```sh cd main/frontend npm install ``` This installs Vite, Sass, HTMX, and Concurrently. ## Development From `main/frontend`, start the normal CORS-free development workflow with one command: ```sh npm run dev ``` Concurrent output is labeled and color-coded: `assets` is cyan and `django` is green. Vite rebuilds SCSS and JavaScript whenever source files change; Django serves the generated assets from its own origin, so there is no request to port `5173`. Refresh the browser after an asset change. The command stops the other process if either process fails. The Django server listens on port `1234`; change the `dev:django` script in `package.json` if you need another port. For environments where the browser can reach Vite directly on port `5173`, use optional HMR instead: ```sh npm run dev:hmr ``` The HMR mode loads Vite's HMR client and `src/main.js` from the Vite server. If Django is served on a different host or port, set `VITE_DEV_SERVER` to the browser-reachable Vite URL. The development server uses `cors: true` deliberately; do not expose it as a production asset server. ## Production build ```sh cd main/frontend npm ci npm run build cd /home/jorenmartijn/django VITE_USE_DEV_SERVER=false tasksnest/bin/python main/manage.py collectstatic ``` `npm run build` writes hashed assets and `.vite/manifest.json` to `planner/static/planner/dist/`. With `VITE_USE_DEV_SERVER=false`, Django's `vite_asset` tag reads that manifest and emits the correct hashed JavaScript and CSS URLs. Build before `collectstatic`; do not commit `node_modules` or the compiled `dist` output unless your deployment intentionally stores built assets in source control.