You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added an example demonstrating how to set environment variables in the Vite config file.
Included a dynamic setup for the latest Git commit hash (VITE_CODE_VERSION) as an environment variable using execSync. This ensures the app can reference the commit hash during build time
Use the define block in Vite to inject global constants or environment variables accessible within the application at build time. While `.env` files should always be used for static variables, dynamic values like the latest Git commit hash can also be set.
122
+
123
+
```js twoslash
124
+
import { defineConfig } from"vite";
125
+
import { execSync } from"child_process";
126
+
127
+
exportdefaultdefineConfig({
128
+
define: {
129
+
// Make the commit hash available as an env varaible in your app
0 commit comments