Skip to content

feat(cli): add preview command for production builds#372

Merged
Brooooooklyn merged 4 commits intomainfrom
add-vite-missing-commands
Dec 29, 2025
Merged

feat(cli): add preview command for production builds#372
Brooooooklyn merged 4 commits intomainfrom
add-vite-missing-commands

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Dec 25, 2025

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 dev and vite build commands.

Additionally:

  • Running vite with no command now defaults to vite dev
  • Running vite with options (like vite --port 3000) is treated as vite dev
  • Added preview to the list of built-in commands
  • Added tests for the new command

Copy link
Copy Markdown
Member Author

fengmk2 commented Dec 25, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fengmk2 fengmk2 self-assigned this Dec 25, 2025
@fengmk2 fengmk2 changed the title feat(cli): add vite optimize and preview subcommands feat(cli): add preview command for production builds Dec 25, 2025
@fengmk2 fengmk2 force-pushed the add-vite-missing-commands branch from c2c350b to 6b7c255 Compare December 25, 2025 14:10
@fengmk2 fengmk2 marked this pull request as ready for review December 26, 2025 06:59
@fengmk2 fengmk2 requested review from Brooooooklyn, branchseer and Copilot and removed request for Copilot December 26, 2025 06:59
fengmk2 and others added 4 commits December 29, 2025 10:34
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>
Copilot AI review requested due to automatic review settings December 29, 2025 10:34
@fengmk2 fengmk2 force-pushed the add-vite-missing-commands branch from 6b7c255 to e56d5c8 Compare December 29, 2025 10:34
Copy link
Copy Markdown
Member Author

fengmk2 commented Dec 29, 2025

Merge activity

  • Dec 29, 10:35 AM UTC: Graphite rebased this pull request as part of a merge.
  • Dec 29, 10:49 AM UTC: Graphite couldn't merge this PR because it was not satisfying all requirements.
  • Dec 29, 12:23 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Dec 29, 12:23 PM UTC: @Brooooooklyn merged this pull request with Graphite.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 preview command with argument forwarding to the underlying Vite CLI
  • Running vite with no arguments now defaults to vite dev
  • Running vite with options (e.g., vite --port 3000) is treated as vite 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.

Comment thread packages/cli/binding/src/lib.rs
@Brooooooklyn Brooooooklyn merged commit 7f7bb67 into main Dec 29, 2025
17 of 18 checks passed
@Brooooooklyn Brooooooklyn deleted the add-vite-missing-commands branch December 29, 2025 12:23
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.

3 participants