coolify/vite.config.js
Andras Bacsai e8dc48e058 fix(vite): make dev server host/port configurable via env vars
Replace hardcoded HMR host with VITE_HOST/VITE_PORT env vars.
Set allowedHosts to true and derive origin/HMR config from env,
falling back to defaults when vars are absent.
2026-04-28 22:06:20 +02:00

45 lines
1.3 KiB
JavaScript

import { defineConfig, loadEnv } from "vite";
import laravel from "laravel-vite-plugin";
import vue from "@vitejs/plugin-vue";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const viteHost = env.VITE_HOST || null;
const vitePort = Number(env.VITE_PORT || 5173);
return {
server: {
watch: {
ignored: [
"**/dev_*_data/**",
"**/storage/**",
],
},
host: "0.0.0.0",
allowedHosts: true,
origin: viteHost ? `http://${viteHost}:${vitePort}` : undefined,
hmr: viteHost
? { host: viteHost, clientPort: vitePort }
: true,
},
plugins: [
laravel({
input: ["resources/css/app.css", "resources/js/app.js"],
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
resolve: {
alias: {
vue: "vue/dist/vue.esm-bundler.js",
},
},
}
});