Skip to content

fix: use import.meta.env.DEV instead of __DEV__ for mode detection#2666

Open
ocean-sudo wants to merge 1 commit into
slidevjs:mainfrom
ocean-sudo:fix/dev-mode-detection
Open

fix: use import.meta.env.DEV instead of __DEV__ for mode detection#2666
ocean-sudo wants to merge 1 commit into
slidevjs:mainfrom
ocean-sudo:fix/dev-mode-detection

Conversation

@ocean-sudo

@ocean-sudo ocean-sudo commented Jul 12, 2026

Copy link
Copy Markdown

Summary

Fixes #2665 — dev server renders blank page when NODE_ENV=production is set.

Root Cause

packages/client/env.ts uses __DEV__ to detect dev mode, but __DEV__ is not auto-defined by Vite 8 when NODE_ENV=production is present in the environment.

Fix

Replace the non-standard __DEV__ with Vite's built-in import.meta.env.DEV:

- export const mode = __DEV__ ? 'dev' : 'build'
+ export const mode = import.meta.env.DEV ? 'dev' : 'build'

import.meta.env.DEV correctly reflects Vite's mode (dev server vs build) regardless of NODE_ENV.

__DEV__ is not auto-defined by Vite 8 when NODE_ENV=production
is set, causing the dev server to render a blank page.
Replace it with import.meta.env.DEV which correctly reflects
Vite dev/prod mode regardless of NODE_ENV.

Fixes slidevjs#2665
@netlify

netlify Bot commented Jul 12, 2026

Copy link
Copy Markdown

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 56abb1d
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/6a53717f25c8e70008fbfe85
😎 Deploy Preview https://deploy-preview-2666--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

__DEV__ is not defined: dev server renders blank page on Vite 8 (Slidev v52)

1 participant