Skip to content

fix(desktop): inject NODE_ENV into main and preload builds#369

Merged
saddlepaddle merged 1 commit intomainfrom
fix/desktop-node-env
Dec 15, 2025
Merged

fix(desktop): inject NODE_ENV into main and preload builds#369
saddlepaddle merged 1 commit intomainfrom
fix/desktop-node-env

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Dec 15, 2025

Summary

  • Fix production builds using .superset-dev instead of .superset
  • Inject NODE_ENV into main and preload process builds via Vite define
  • Defaults to "production" when not set (matches expected behavior for packaged apps)

Root cause

The renderer build had NODE_ENV: "production" injected via injectProcessEnvPlugin, but main/preload builds relied on process.env.NODE_ENV at runtime, which isn't set in packaged Electron apps.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated build configuration to ensure consistent environment variable handling across build pipelines.

✏️ Tip: You can customize this high-level summary in your review settings.

The main and preload processes weren't getting NODE_ENV set during
production builds, causing the app to use development paths like
.superset-dev instead of .superset.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 15, 2025

Walkthrough

Adds environment variable definitions to the Electron Vite configuration file by introducing define blocks in both the main and preload sections. These ensure process.env.NODE_ENV is stringified and available during the build, defaulting to "production" if undefined.

Changes

Cohort / File(s) Summary
Electron Vite Configuration
apps/desktop/electron.vite.config.ts
Added define block with process.env.NODE_ENV to both main and preload sections, stringifying the environment variable or defaulting to "production"

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Straightforward configuration-only change with identical additions to two sections
  • No logic modifications or control flow impacts
  • Minimal surface area affecting a single file

Poem

🐰 The config now whispers, so clear and so bright,
"process.env.NODE_ENV" takes flight!
In main and preload, the env is defined,
Build-time constants, perfectly aligned! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description provides context and root cause analysis but lacks the structured format of the template with sections like Type of Change, Testing, and Related Issues. Complete the PR description by adding the missing template sections (Type of Change, Testing, Related Issues) to improve clarity and consistency with repository standards.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: injecting NODE_ENV into main and preload builds in the Electron Vite config.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/desktop-node-env

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c033829 and 2849d29.

📒 Files selected for processing (1)
  • apps/desktop/electron.vite.config.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
apps/desktop/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc

Files:

  • apps/desktop/electron.vite.config.ts
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: Please use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary

Files:

  • apps/desktop/electron.vite.config.ts
**/*.{ts,tsx,js,jsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome for code formatting and linting, running at root level for speed

Files:

  • apps/desktop/electron.vite.config.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Avoid any type and prioritize type safety in TypeScript code

Files:

  • apps/desktop/electron.vite.config.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-12T05:45:09.686Z
Learning: Applies to apps/desktop/src/main/index.ts : Load environment variables in apps/desktop/src/main/index.ts with override: true before any imports
📚 Learning: 2025-12-12T05:45:09.686Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-12T05:45:09.686Z
Learning: Applies to apps/desktop/src/main/index.ts : Load environment variables in apps/desktop/src/main/index.ts with override: true before any imports

Applied to files:

  • apps/desktop/electron.vite.config.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Deploy API
  • GitHub Check: Deploy Admin
  • GitHub Check: Deploy Marketing
  • GitHub Check: Deploy Web
  • GitHub Check: Deploy Docs
  • GitHub Check: Build
🔇 Additional comments (2)
apps/desktop/electron.vite.config.ts (2)

57-61: LGTM - Correctly injects NODE_ENV for main process.

The define block properly injects process.env.NODE_ENV at build time with a sensible default to "production". This ensures packaged Electron apps have NODE_ENV available, addressing the root cause of the .superset-dev vs .superset issue.


91-95: LGTM - Consistent NODE_ENV injection for preload process.

The preload define block correctly mirrors the main section's approach, ensuring consistent NODE_ENV availability across both the main and preload processes in packaged builds.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 15, 2025

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

Service Status
Neon Database (Neon)

Thank you for your contribution! 🎉


Preview resources have been processed for cleanup

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.

1 participant