-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manually define process.env vars needed on client
- Loading branch information
1 parent
773e476
commit 526e235
Showing
3 changed files
with
37 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,32 @@ | ||
import { defineConfig, loadEnv } from 'vite'; | ||
import react from '@vitejs/plugin-react' | ||
import { defineConfig, loadEnv } from "vite"; | ||
import react from "@vitejs/plugin-react"; | ||
|
||
export default defineConfig(({ mode }) => { | ||
const env = loadEnv(mode, process.cwd(), ''); | ||
console.log('ENV', env); | ||
return { | ||
base: env.VITE_APP_CONFIG_BASE, | ||
plugins: [react()], | ||
define: { | ||
'process.env.VITE_APP_CONFIG_BASE': env.VITE_APP_CONFIG_BASE, | ||
'process.env.VITE_APP_ORDERCLOUD_CLIENT_ID': env.VITE_APP_ORDERCLOUD_CLIENT_ID, | ||
'process.env.VITE_APP_ORDERCLOUD_SCOPE': env.VITE_APP_ORDERCLOUD_SCOPE, | ||
'process.env.VITE_APP_ORDERCLOUD_CUSTOM_SCOPE': env.VITE_APP_ORDERCLOUD_CUSTOM_SCOPE, | ||
'process.env.VITE_APP_ORDERCLOUD_ALLOW_ANONYMOUS': env.VITE_APP_ORDERCLOUD_ALLOW_ANONYMOUS, | ||
} | ||
}; | ||
}); | ||
const env = loadEnv(mode, process.cwd(), ""); | ||
console.log("ENV", env); | ||
const definitions = { | ||
"process.env.VITE_APP_CONFIG_BASE": JSON.stringify( | ||
env.VITE_APP_CONFIG_BASE | ||
), | ||
"process.env.VITE_APP_ORDERCLOUD_BASE_API_URL": JSON.stringify( | ||
env.VITE_APP_ORDERCLOUD_BASE_API_URL | ||
), | ||
"process.env.VITE_APP_ORDERCLOUD_CLIENT_ID": JSON.stringify( | ||
env.VITE_APP_ORDERCLOUD_CLIENT_ID | ||
), | ||
"process.env.VITE_APP_ORDERCLOUD_SCOPE": JSON.stringify( | ||
env.VITE_APP_ORDERCLOUD_SCOPE | ||
), | ||
"process.env.VITE_APP_ORDERCLOUD_CUSTOM_SCOPE": JSON.stringify( | ||
env.VITE_APP_ORDERCLOUD_CUSTOM_SCOPE | ||
), | ||
"process.env.VITE_APP_ORDERCLOUD_ALLOW_ANONYMOUS": JSON.stringify( | ||
env.VITE_APP_ORDERCLOUD_ALLOW_ANONYMOUS | ||
), | ||
}; | ||
return { | ||
base: env.VITE_APP_CONFIG_BASE, | ||
plugins: [react()], | ||
define: definitions, | ||
}; | ||
}); |