question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Built in Vite env vars seem incorrect in prerender hook

See original GitHub issue

Repro Steps:

  1. Add a console.log of import.meta.env from inside a page’s prerender hook
  2. Run prerender process, e.g. cross-env NODE_ENV=production && npm run build && vite-plugin-ssr prerender --clientRouter
  3. Observe that logged env indicates the following:
MODE: 'production'
DEV: true
PROD: false

Expected Results: Having specified NODE_ENV=production, I would expect DEV=false, PROD=true. Additionally, I would expect SSR=true to come through, but it is not showing up at all.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
brilloutcommented, Apr 6, 2021

Yes I can confirm that the SSR env is missing in prod. I’m confident the problem is on Vite’s side. It should be easy to reproduce on https://github.com/vitejs/vite/tree/main/packages/playground/ssr-vue.

0reactions
gryphonmyerscommented, Apr 7, 2021

OK going to go ahead and close this then. For clarity, I believe the fix here was removeing && in my npm script per brillout’s suggestion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Env Variables and Modes - Vite
Vite exposes env variables on the special import.meta.env object. Some built-in variables are available in all cases: import.meta.env.
Read more >
Consistent handling of environment variables #4296 - GitHub
Describe the problem SvelteKit doesn't do anything special with environment variables; it delegates to Vite. This is good for the sorts of ...
Read more >
Learn How SvelteKit Works As a Framework - Joy of Code
Kit isn't built on top of Svelte but it's a backend web framework where Svelte is used as the view layer but in...
Read more >
Test runner Addon | Storybook: Frontend workshop for UI ...
The test runner supports code coverage with the --coverage flag or STORYBOOK_COLLECT_COVERAGE environment variable. The pre-requisite is that your components ...
Read more >
Server-Side Rendering (SSR) - Vue.js
If the data needed to server-render a page is the same for every user, then instead of rendering the page every time a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found