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

fix: check if build exists so preview doesn't show 404s due to nonexistent build #10564

Merged
merged 5 commits into from
Dec 10, 2022

Conversation

fc
Copy link
Contributor

@fc fc commented Oct 20, 2022

Description

Problem:
When running vite preview and no build has been made yet, then it will show 404s on all routes in the browser.

Solution:
Error out if dir does not exist.

Displays an error like this if it does not exist:

error when starting preview server:
Error: "dist" does not exist. Create build then try again.
    at CAC.<anonymous> (file:///Users/fc/tmp/vite-fc/packages/vite/dist/node/cli.js:814:19)

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@fc fc changed the title fix: check if file exists when attempting to preview. fix: check if build exists when attempting to preview Oct 20, 2022
@fc fc marked this pull request as ready for review October 20, 2022 23:21
@fc fc changed the title fix: check if build exists when attempting to preview fix: check if build exists so preview doesn't show 404s due to nonexistent build Oct 24, 2022
fc and others added 4 commits November 8, 2022 17:35
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
@sapphi-red sapphi-red added the p2-nice-to-have Not breaking anything but nice to have (priority) label Nov 26, 2022
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

This slipped of my radar 😅 Should be a simple feature to merge

@patak-dev patak-dev merged commit 0a1db8c into vitejs:main Dec 10, 2022
@sapphi-red sapphi-red mentioned this pull request Dec 11, 2022
4 tasks
@dominikg
Copy link
Contributor

unfortunately this PR is a breaking change. Throwing an Error where there was none thrown before, and it breaks plugins using configurePreviewServer to customize.

case in point: pnm build && pnpm preview no longer works in in a sveltekit project with this change.

sveltekit code that is used in configurePreviewServer

dominikg added a commit to dominikg/vite that referenced this pull request Dec 12, 2022
…how 404s due to nonexistent build (vitejs#10564)"

This reverts commit 0a1db8c
patak-dev pushed a commit that referenced this pull request Dec 12, 2022
fix(preview): Revert "fix: check if build exists so preview doesn't show 404s due to nonexistent build (#10564)"

This reverts commit 0a1db8c
futurGH pushed a commit to futurGH/vite that referenced this pull request Feb 26, 2023
…stent build (vitejs#10564)

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
futurGH pushed a commit to futurGH/vite that referenced this pull request Feb 26, 2023
…tejs#11335)

fix(preview): Revert "fix: check if build exists so preview doesn't show 404s due to nonexistent build (vitejs#10564)"

This reverts commit 0a1db8c
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
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants