Support env variables for vite config

This commit is contained in:
Andrew Kingston 2022-08-16 09:26:23 +00:00
parent 1ef1cc84ad
commit 4c6b9a03d1
1 changed files with 9 additions and 2 deletions

View File

@ -1,15 +1,22 @@
import { svelte } from "@sveltejs/vite-plugin-svelte" import { svelte } from "@sveltejs/vite-plugin-svelte"
import replace from "@rollup/plugin-replace" import replace from "@rollup/plugin-replace"
import { defineConfig, loadEnv } from "vite"
import path from "path" import path from "path"
export default ({ mode }) => { export default defineConfig(({ mode }) => {
const isProduction = mode === "production" const isProduction = mode === "production"
const env = loadEnv(mode, process.cwd())
return { return {
server: { server: {
fs: { fs: {
strict: false, strict: false,
}, },
hmr: {
protocol: "wss",
clientPort: env.VITE_HMR_CLIENT_PORT || 3000,
path: env.VITE_HMR_PATH || "/"
}
}, },
base: "/builder/", base: "/builder/",
build: { build: {
@ -79,4 +86,4 @@ export default ({ mode }) => {
], ],
}, },
} }
} })