File tree Expand file tree Collapse file tree 4 files changed +10
-31
lines changed
Expand file tree Collapse file tree 4 files changed +10
-31
lines changed Original file line number Diff line number Diff line change 1-
2-
31// eslint-disable-next-line import/prefer-default-export
4- export const env = { ...import . meta. env , ...window . config } ;
2+ export const env = { ...import . meta. env , ...( globalThis . window ? .config ?? { } ) } ;
Original file line number Diff line number Diff line change 55 < link rel ="icon " href ="/favicon.ico " />
66 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
77 < title > BCGov Public Code</ title >
8+ < script src ="/env.js "> </ script >
89 </ head >
910 < body >
1011 < div id ="root "> </ div >
Original file line number Diff line number Diff line change 1+ // Runtime configuration loaded before the Vite bundle.
2+ // In production, Caddy serves /env.js and overwrites this response.
3+
4+ window . config = window . config || {
5+ VITE_SCHEMA_BRANCH : "main" ,
6+ VITE_POWERBI_URL : "" ,
7+ } ;
Original file line number Diff line number Diff line change @@ -3,38 +3,11 @@ import react from "@vitejs/plugin-react";
33
44// https://vite.dev/config/
55export default defineConfig ( {
6- plugins : [
7- {
8- name : "build-html" ,
9- apply : "build" ,
10- transformIndexHtml : ( html ) => {
11- return {
12- html,
13- tags : [
14- {
15- tag : "script" ,
16- attrs : {
17- src : "/env.js" ,
18- } ,
19- injectTo : "head" ,
20- } ,
21- ] ,
22- } ;
23- } ,
24- } ,
25- react ( ) ,
26- ] ,
6+ plugins : [ react ( ) ] ,
277 server : {
288 port : 3001 ,
299 proxy : {
3010 "/api" : "http://localhost:3000" ,
3111 } ,
3212 } ,
33- define : {
34- // Define window.config for build time - will be overridden by Caddy in production
35- "window.config" : JSON . stringify ( {
36- VITE_SCHEMA_BRANCH : "main" ,
37- VITE_POWERBI_URL : "" ,
38- } ) ,
39- } ,
4013} ) ;
You can’t perform that action at this time.
0 commit comments