Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: normalize scripts and commands naming #5207

Merged
merged 3 commits into from
Oct 27, 2021

Conversation

patak-dev
Copy link
Member

Description

See #5097 for context. That PR explored what would be needed to change serve by dev everywhere, also in the internal API. As plugins are already using config.command === 'serve', it is hard to justify such a breaking change for the ecosystem.

Looks like SvelteKit, Astro and others are using preview as a script name without issues. Maybe this is only a problem when there is a view script? (but that would be already in the hands of the user to arrange). So, this PR changes the current setup from:

vite / vite serve   / pnpm run dev   | the dev server
       vite build   / pnpm run build | the build command
       vite preview / pnpm run serve | the preview server

to:

vite / vite dev     / pnpm run dev     | the dev server ('serve' in the API)
       vite build   / pnpm run build   | the build command
       vite preview / pnpm run preview | the preview server
  1. pnpm run serve -> pnpm run preview. This is only used internally and in templates, so we don't need to keep the old script around. We could add the script and log a message for a while but it may be overkill and add noise to the starter templates.

  2. dev is introduced as an alias for serve to run the dev server. Current users are used to seeing dev as the script name, and this aligns Vite to other tools in the ecosystem.

  3. serve isn't deprecated at this point, because the internal API still uses command === 'serve'. IMO it is best to keep both aliases for the cli.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Copy link
Member

@antfu antfu left a comment

Choose a reason for hiding this comment

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

I am good with these changes. But maybe let's have Evan aware of this first in today's meeting?

@patak-dev
Copy link
Member Author

We decided to move forward with this change. I think we can do it in the next minor even if it doesn't affect core with a breaking change, and only create-vite. I'll update the docs to make it more clear that vite dev and vite serve are equivalent before we merge it.

@patak-dev patak-dev added the p2-nice-to-have Not breaking anything but nice to have (priority) label Oct 8, 2021
@patak-dev patak-dev added this to the 2.7 milestone Oct 8, 2021
@patak-dev
Copy link
Member Author

I'll merge this one and then send another PR with a new section for the CLI in the docs. We don't really have a CLI reference at this point so it is hard to see where to properly add this info.

@patak-dev patak-dev merged commit 22873a7 into main Oct 27, 2021
@patak-dev patak-dev deleted the scripts-and-commands-naming branch October 27, 2021 12:32
@patak-dev patak-dev mentioned this pull request Oct 30, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants