Built in Vite env vars seem incorrect in prerender hook
See original GitHub issueRepro Steps:
- Add a console.log of
import.meta.env
from inside a page’s prerender hook - Run prerender process, e.g.
cross-env NODE_ENV=production && npm run build && vite-plugin-ssr prerender --clientRouter
- 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:
- Created 2 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.