Support env variables for vite config

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

View File

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