Skip to content

Commit

Permalink
fix: SSR env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobrosenberg committed Jan 21, 2025
1 parent f0cd027 commit b37d4a8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/extra/vite-plugin/vite-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ let isSsr = false
export default function RoutifyPlugin(input = {}) {
const options = normalizeOptions(input, isProduction)
optionsCheck(options, isProduction)

process.env.ROUTIFY_SSR_ENABLE = JSON.stringify(options.render.ssr.enable || '')
/** @ts-ignore*/
process.env.ROUTIFY_SSR_ENABLE = !!options.render.ssr.enable

return {
name: 'routify-plugin',
Expand Down Expand Up @@ -56,7 +56,10 @@ export default function RoutifyPlugin(input = {}) {
: cfg.build?.ssr,
outDir: `${options.outDir}/${cfg.build?.ssr ? 'server' : 'client'}`,
},
envPrefix: ['VITE_', 'ROUTIFY_SSR_ENABLE'],
envPrefix: ['VITE_', 'ROUTIFY_'], // Ensure ROUTIFY_ prefix is parsed
define: {
'import.meta.env.ROUTIFY_SSR_ENABLE': process.env.ROUTIFY_SSR_ENABLE,
},
}
},
transformIndexHtml: html => {
Expand Down

0 comments on commit b37d4a8

Please sign in to comment.