diff --git a/frontend/example.env b/frontend/example.env index 93d83d9..1b52056 100755 --- a/frontend/example.env +++ b/frontend/example.env @@ -4,3 +4,4 @@ VITE_ENV=local VITE_VERSION_NUMBER=v0.0.1 VITE_API_URL= VITE_GA_TRACKING_ID= +VITE_DOCKER=false diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 00f2f69..90e7bf6 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,4 +1,4 @@ -import { defineConfig, loadEnv } from "vite"; +import { defineConfig, loadEnv, ServerOptions } from "vite"; import react from "@vitejs/plugin-react"; import { pigment } from "@pigment-css/vite-plugin"; import theme from "./src/themes/theme"; @@ -7,6 +7,14 @@ import path from "path"; export default ({ mode }: { mode: string }) => { process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }; + const serverOptions: ServerOptions = { + port: Number(process.env.VITE_PORT), + }; + if (process.env.VITE_DOCKER === "true") { + serverOptions.host = true; + serverOptions.watch = { usePolling: true }; + } + return defineConfig({ plugins: [ react(), @@ -18,16 +26,7 @@ export default ({ mode }: { mode: string }) => { build: { sourcemap: process.env.VITE_GENERATE_SOURCEMAP === "true", }, - server: { - port: Number(process.env.VITE_PORT), - // DOCKER SETUP - // add the next lines so that it works on docker - // host: true, - // add the next lines if you're using windows and hot reload doesn't work - // watch: { - // usePolling: true, - // }, - }, + server: serverOptions, define: { __ENV__: JSON.stringify(process.env.VITE_ENV), __API_URL__: JSON.stringify(process.env.VITE_API_URL),