feat(cli): add preview command for production builds#372
Merged
Brooooooklyn merged 4 commits intomainfrom Dec 29, 2025
Merged
Conversation
c2c350b to
6b7c255
Compare
Brooooooklyn
approved these changes
Dec 29, 2025
Add two new Vite CLI subcommands that forward arguments to the underlying Vite CLI: - `vite optimize`: Pre-bundle dependencies (with --force option) - `vite preview`: Preview production build (with --port, --host, etc.) Both commands follow the same pattern as existing `vite dev` and `vite build` commands. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add optimize and preview to LOCAL_CLI_COMMANDS so they are properly forwarded to the local CLI instead of being handled by the global Rust binary. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The vite optimize command is deprecated as dependency pre-bundling now runs automatically. Only keep the vite preview command. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Running `vite` without arguments or with options (e.g., `vite --port 3000`) now defaults to the dev command, matching the behavior of the upstream Vite CLI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
6b7c255 to
e56d5c8
Compare
Member
Author
Merge activity
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new vite preview command to preview production builds and enhances the CLI to default to vite dev when run without a command. The implementation follows the existing pattern for builtin commands like build, dev, test, etc.
Key changes:
- Added
vite previewcommand with argument forwarding to the underlying Vite CLI - Running
vitewith no arguments now defaults tovite dev - Running
vitewith options (e.g.,vite --port 3000) is treated asvite dev --port 3000
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
packages/global/src/index.ts |
Added preview to the list of local CLI commands |
packages/cli/binding/src/lib.rs |
Added preview to builtin commands array and refactored argument parsing to handle default dev command and option forwarding |
packages/cli/binding/src/cli.rs |
Added Preview command variant, implementation handler that forwards to vite CLI, and unit tests |
packages/cli/snap-tests/command-preview/steps.json |
New test configuration for preview command using invalid port to verify command forwarding |
packages/cli/snap-tests/command-preview/snap.txt |
Expected output snapshot for preview command test |
packages/cli/snap-tests/command-preview/package.json |
Empty package.json for preview test fixture |
packages/cli/snap-tests/command-helper/steps.json |
Added tests for preview and dev help messages |
packages/cli/snap-tests/command-helper/snap.txt |
Updated snapshot with preview command help output |
packages/cli/snap-tests/command-dev-with-port/steps.json |
Added test verifying vite --port defaults to dev command |
packages/cli/snap-tests/command-dev-with-port/snap.txt |
Updated snapshot with test output for vite without command |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Add a new Vite CLI subcommand that forwards arguments to the underlying Vite CLI:
vite preview: Preview production build (with --port, --host, etc.)This command follows the same pattern as existing
vite devandvite buildcommands.Additionally:
vitewith no command now defaults tovite devvitewith options (likevite --port 3000) is treated asvite devpreviewto the list of built-in commands