refactor(vite): improve environment variable handling in Vite configuration

This commit is contained in:
Andras Bacsai
2025-01-27 13:52:25 +01:00
parent 50750eb9e4
commit 2d3ac5a62a

View File

@@ -1,8 +1,11 @@
import { defineConfig } from "vite"; import { defineConfig, loadEnv } from "vite";
import laravel from "laravel-vite-plugin"; import laravel from "laravel-vite-plugin";
import vue from "@vitejs/plugin-vue"; import vue from "@vitejs/plugin-vue";
export default defineConfig({ export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
server: { server: {
watch: { watch: {
ignored: [ ignored: [
@@ -12,7 +15,7 @@ export default defineConfig({
}, },
host: "0.0.0.0", host: "0.0.0.0",
hmr: { hmr: {
host: process.env.VITE_HOST, host: env.VITE_HOST || '0.0.0.0'
}, },
}, },
plugins: [ plugins: [
@@ -34,4 +37,5 @@ export default defineConfig({
vue: "vue/dist/vue.esm-bundler.js", vue: "vue/dist/vue.esm-bundler.js",
}, },
}, },
}
}); });