-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
vite: Enable use of vite preview
to preview built SPA sites
#8624
Conversation
🦋 Changeset detectedLatest commit: 4a757cc The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I also implemented the required Remix changes as a patch against And for |
732b27c
to
1fa723c
Compare
vite preview
to preview built SPA sites
1fa723c
to
d222686
Compare
What is the "SPA Fallback" you're referring to here? Remix SPA mode renders the root
I kind of liked |
oh, I see the linked issue now - nvm my question about the fallback, we can discuss in #8623 |
I was using what seemed to be the most common parlance used in the web server discussions, but it's not super obvious. I meant the option to serve up the root-directory |
58587bf
to
4e21925
Compare
4e21925
to
868c2dc
Compare
@brophdawg11 I see that you are about to stabilize SPA mode. I just rebased this on the most recent Let me know if you have any suggestions for what you would like to see changed. |
868c2dc
to
fb3fbb3
Compare
fb3fbb3
to
a8453b0
Compare
Set appType: "spa" Ensure outDir gets passed through
a8453b0
to
4a757cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
This enables use of
vite preview
for serving built SPA sites. This works better thanhttp-server
because it correctly supports the SPA fallback (i.e. serving a statically deployed site with all routes being served from a root/index.html
).This is more than a template change because the Remix Vite plugin was setting
appType: "custom"
, preventingvite preview
from working in"spa"
mode. The patch also sets thebuild.outDir
when previewing so additional command line options aren't needed.The SPA template has been updated to use
npm run preview
(oryarn preview
) to preview the built site. Thestart
script (npm run start
) has been removed from the SPA template because it isn't something that should be used in production.Closes #8623
Testing Strategy:
I opened up my windows machine and ran this script (PowerShell):
Open browser to link provided by
vite preview
and click on the "Navigate" link to arrive athttp://localhost:4173/hello
(port may differ). Refresh the page (e.g.F5
), and the page should load without a 404. Also try navigating directly to that URL in a new tab.