Skip to content

Commit

Permalink
Update env usage for new conventions in Vite 4
Browse files Browse the repository at this point in the history
There were a couple of improvements in the updated version of Vite
around decoupling build modes and NODE_ENV:

* vitejs/vite#10996
* vitejs/vite#11045

Accordingly, this change:

* Consistently uses import.meta.env.MODE to set build mode specific
  values vs relying on the (previous) behavior around how
  import.meta.env.PROD was set.
* Adds a development environment file so NODE_ENV is set to development
  for this builds.
  • Loading branch information
rnathuji committed Jan 13, 2023
1 parent 847aa22 commit 3e29722
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.development
@@ -0,0 +1 @@
NODE_ENV=development
4 changes: 2 additions & 2 deletions src/lib/env.ts
@@ -1,10 +1,10 @@
export const ENV = {
OS_RAISE_CONTENT_URL_PREFIX: import.meta.env.PROD ? 'https://k12.openstax.org/contents/raise' : 'http://localhost:8800/contents',
OS_RAISE_CONTENT_URL_PREFIX: import.meta.env.MODE === 'production' ? 'https://k12.openstax.org/contents/raise' : 'http://localhost:8800/contents',
OS_RAISE_EVENTSAPI_URL_MAP: {},
EVENT_FLUSH_PERIOD: 60000
}

if (import.meta.env.PROD) {
if (import.meta.env.MODE === 'production') {
ENV.OS_RAISE_EVENTSAPI_URL_MAP = {
'raiselearning.org': 'https://events.raiselearning.org',
'staging.raiselearning.org': 'https://events.staging.raiselearning.org'
Expand Down

0 comments on commit 3e29722

Please sign in to comment.