File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 < link rel ="icon " type ="image/svg+xml " href ="/favicon.svg " />
99 < link rel ="icon " type ="image/png " sizes ="16x16 " href ="/favicon-16x16.png " />
1010 < link rel ="apple-touch-icon " href ="/favicon.svg " />
11- < script >
12- // Analytics will be loaded dynamically based on environment variables
13- if ( typeof __ANALYTICS_ENABLED__ !== 'undefined' && __ANALYTICS_ENABLED__ ) {
14- const script = document . createElement ( 'script' ) ;
15- script . async = true ;
16- script . src = __ANALYTICS_URL__ ;
17- script . setAttribute ( 'data-website-id' , __ANALYTICS_WEBSITE_ID__ ) ;
18- document . head . appendChild ( script ) ;
19- }
20- </ script >
2111</ head >
2212
2313< body class ="bg-slate-950 text-slate-100 ">
Original file line number Diff line number Diff line change @@ -3,6 +3,15 @@ import ReactDOM from "react-dom/client";
33import App from "./App" ;
44import "./styles.css" ;
55
6+ // Load analytics script if enabled
7+ if ( import . meta. env . VITE_ANALYTICS_ENABLED === 'true' ) {
8+ const script = document . createElement ( 'script' ) ;
9+ script . defer = true ;
10+ script . src = import . meta. env . VITE_ANALYTICS_URL ;
11+ script . setAttribute ( 'data-website-id' , import . meta. env . VITE_ANALYTICS_WEBSITE_ID ) ;
12+ document . head . appendChild ( script ) ;
13+ }
14+
615ReactDOM . createRoot ( document . getElementById ( "root" ) as HTMLElement ) . render (
716 < React . StrictMode >
817 < App />
Original file line number Diff line number Diff line change @@ -3,10 +3,4 @@ import react from "@vitejs/plugin-react";
33
44export default defineConfig ( {
55 plugins : [ react ( ) ] ,
6- define : {
7- // Make environment variables available at build time
8- __ANALYTICS_URL__ : JSON . stringify ( process . env . VITE_ANALYTICS_URL || "https://analytics.website/script.js" ) ,
9- __ANALYTICS_WEBSITE_ID__ : JSON . stringify ( process . env . VITE_ANALYTICS_WEBSITE_ID || "YOUR_WEBSITE_ID" ) ,
10- __ANALYTICS_ENABLED__ : JSON . stringify ( process . env . VITE_ANALYTICS_ENABLED === "true" ) ,
11- } ,
126} ) ;
You can’t perform that action at this time.
0 commit comments