Skip to content

feat(build): support custom framework preview/deploy commands#4293

Open
danielroe wants to merge 1 commit into
mainfrom
feat/framework-commands
Open

feat(build): support custom framework preview/deploy commands#4293
danielroe wants to merge 1 commit into
mainfrom
feat/framework-commands

Conversation

@danielroe
Copy link
Copy Markdown
Member

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

testing vite environment api with nuxt, I was surprised to see this printed out at the end of the build:

ℹ Generated playground/.output/nitro.json
✔ You can preview this build using npx vite preview
│
└  ✨ Build complete!

I think it makes sense for frameworks with their own CLI to provide a custom preview/deploy command rather than hard-coding it to vite preview, or nitro deploy.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe requested a review from pi0 as a code owner May 30, 2026 07:48
@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nitro.build Ready Ready Preview, Comment May 30, 2026 7:50am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 30, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR extends the Nitro framework information type with optional previewCommand and deployCommand fields, then updates build output success messages in both rolldown and vite to use these framework-configurable commands instead of hardcoded Nitro defaults.

Changes

Framework-aware build command hints

Layer / File(s) Summary
Framework command configuration contract
src/types/nitro.ts
NitroFrameworkInfo interface now includes optional previewCommand and deployCommand string properties for framework-specific build output guidance, with Nitro commands as defaults when not provided.
Build output preview and deploy commands
src/build/rolldown/prod.ts, src/build/vite/prod.ts
Success messages in both rolldown and vite build systems now resolve preview and deploy commands from nitro.options.framework with fallbacks to the original hardcoded npx nitro preview and npx nitro deploy --prebuilt strings.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • nitrojs/nitro#4042: Both PRs modify the user-facing build preview/deploy guidance in src/build/*/prod.ts by changing how deploy command text is constructed and displayed.
  • nitrojs/nitro#4024: Introduces the new nitro preview CLI command that the framework-configurable hints in this PR are designed to wrap or override.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commits format with 'feat(build):' prefix and clearly describes the main feature: supporting custom framework preview/deploy commands.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation for adding framework-configurable preview/deploy commands to address hard-coded build output messages.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/framework-commands

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 30, 2026

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4293

commit: 98b0ed6

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/build/vite/prod.ts`:
- Around line 123-124: The current fallback for previewCommand (const
previewCommand) uses "npx nitro preview" and may not work for plain Vite
outputs; verify whether the nitro CLI exposes a compatible preview subcommand
and supports Vite .output, and if it does not, change the fallback used in the
previewCommand assignment (and the nitro.logger.success message) to "npx vite
preview" or implement logic to pick "npx nitro preview" only when nitro supports
preview (e.g., feature-detect the CLI or an option on the build result); update
the previewCommand initialization and the nitro.logger.success call accordingly
so plain Vite users are pointed at a working preview command.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ff81c96a-200e-4324-ab3d-5374fb3fb484

📥 Commits

Reviewing files that changed from the base of the PR and between 255b254 and 98b0ed6.

📒 Files selected for processing (3)
  • src/build/rolldown/prod.ts
  • src/build/vite/prod.ts
  • src/types/nitro.ts

Comment thread src/build/vite/prod.ts
Comment on lines +123 to +124
const previewCommand = nitro.options.framework.previewCommand || "npx nitro preview";
nitro.logger.success(`You can preview this build using \`${previewCommand}\``);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Default preview hint changed from npx vite preview to npx nitro preview for plain Vite users.

Previously this message hardcoded npx vite preview (per the PR description). Now, when a framework does not set previewCommand, the fallback is npx nitro preview. Confirm that npx nitro preview actually works against a Vite-produced .output; otherwise plain Vite users (no framework override) are now pointed at a command that may not run their build.

#!/bin/bash
# Does the nitro CLI expose a `preview` command, and does it support vite builds?
rg -nP -C3 "['\"]preview['\"]" --type=ts -g 'src/cli/**'
fd -t f . src/cli --exec rg -nl 'preview' {}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/build/vite/prod.ts` around lines 123 - 124, The current fallback for
previewCommand (const previewCommand) uses "npx nitro preview" and may not work
for plain Vite outputs; verify whether the nitro CLI exposes a compatible
preview subcommand and supports Vite .output, and if it does not, change the
fallback used in the previewCommand assignment (and the nitro.logger.success
message) to "npx vite preview" or implement logic to pick "npx nitro preview"
only when nitro supports preview (e.g., feature-detect the CLI or an option on
the build result); update the previewCommand initialization and the
nitro.logger.success call accordingly so plain Vite users are pointed at a
working preview command.

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