Files
coolify/vite.config.js
T
Andras BacsaiandClaude Opus 5.5 338f1f837f feat(dev): run one isolated dev instance per git branch
Merge scripts/dev-instances into scripts/dev. Each branch gets its own
Compose project, container, volumes, port block, libvirt network, and
KVM VMs, so stop and start reuse the same data and worktrees do not
collide.

- Name instances after the branch; keep slots and APP_KEYs in the main
  checkout's .dev-instances/ so they survive worktree removal
- Reuse existing QEMU VMs instead of recreating them; add dev:qemu --fresh
- Give each instance an isolated libvirt network (10.221.<slot>.0/24)
  and VM names coolify-dev-<branch>--<profile>
- Publish per-instance browser ports and publish them with tailscale
  serve when APP_URL is a tailnet host
- Add urls, exec, logs, container, destroy, and teardown commands; run
  teardown from jean.json before Jean deletes a worktree
- Fix Reverb/terminal browser ports and the testing-host alias in the
  instance compose file
- Keep fresh worktree instances working: pre-create laravel.log, log the
  host dev:qemu call to stderr, and stop Vite from watching vendor/

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 11:55:49 +02:00

52 lines
1.7 KiB
JavaScript

import { defineConfig, loadEnv } from "vite";
import laravel from "laravel-vite-plugin";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
// Prefer process.env so Docker Compose can override without writing .env.
// Set VITE_HOST to a browser-reachable hostname/IP when accessing the app
// from another device (LAN / Tailscale), e.g. VITE_HOST=100.75.155.70
const viteHost = (process.env.VITE_HOST || env.VITE_HOST || "localhost").trim();
const viteHmrHost = (
process.env.VITE_HMR_HOST ||
env.VITE_HMR_HOST ||
viteHost
).trim();
const vitePort = Number(process.env.VITE_PORT || env.VITE_PORT || 5173);
const viteProtocol = (
process.env.VITE_PROTOCOL ||
env.VITE_PROTOCOL ||
"http"
).trim();
return {
server: {
watch: {
ignored: ["**/dev_*_data/**", "**/storage/**", "**/vendor/**"],
},
// Listen on all interfaces so Docker / remote clients can reach the dev server
host: "0.0.0.0",
port: vitePort,
strictPort: true,
allowedHosts: true,
// App (:8000) and Vite (:5173) are different origins; allow any host in dev
cors: true,
origin: `${viteProtocol}://${viteHost}:${vitePort}`,
hmr: {
host: viteHmrHost,
clientPort: vitePort,
protocol: viteProtocol === "https" ? "wss" : "ws",
},
},
plugins: [
laravel({
input: [
"resources/css/app.css",
"resources/js/app.js",
],
refresh: true,
}),
],
};
});