refactor(vite): improve environment variable handling in Vite configuration
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import { defineConfig } from "vite";
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
import laravel from "laravel-vite-plugin";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
|
||||
export default defineConfig({
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), '')
|
||||
|
||||
return {
|
||||
server: {
|
||||
watch: {
|
||||
ignored: [
|
||||
@@ -12,7 +15,7 @@ export default defineConfig({
|
||||
},
|
||||
host: "0.0.0.0",
|
||||
hmr: {
|
||||
host: process.env.VITE_HOST,
|
||||
host: env.VITE_HOST || '0.0.0.0'
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
@@ -34,4 +37,5 @@ export default defineConfig({
|
||||
vue: "vue/dist/vue.esm-bundler.js",
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user