From 4c6b9a03d19b210695207e685a7967881bb643ed Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 16 Aug 2022 09:26:23 +0000 Subject: [PATCH] Support env variables for vite config --- packages/builder/vite.config.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/builder/vite.config.js b/packages/builder/vite.config.js index 56ffbf20f5..9859e1dbb9 100644 --- a/packages/builder/vite.config.js +++ b/packages/builder/vite.config.js @@ -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 }) => { ], }, } -} +})