-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat: preview config #5514
feat: preview config #5514
Conversation
@patak-js Is this really a |
It is a feat, it adds new config options. You can now specify the preview server port in vite.config.js |
Add a test that uses the new preview property
Could you also please provide an example how such a new vite config would look like? 🙂 We should also think about that |
Added docs for preview. @Shinigami92 I checked how we could test the preview server and it isn't clear. We are currently using a custom static server during build test, maybe a good way to test it would be to replace it with the preview server. But this needs to be analyzed separately from this PR vite/scripts/jestPerTestSetup.ts Line 158 in 09e2a5f
I'll merge this without extra tests at this point, test coverage remains the same as before this PR (we are only testing that the preview server starts correctly in the cli playground). |
@patak-js What I would like to get tested is the preview property, so it get's read out from the config |
Description
Continuation from #5407
We create a new
userConfig.preview: { port: 5000, ... }
config option and aresolvedConfig.preview
that has the resolved info for the preview server. There is a newCommonServerOptions
interface that is shared and a newPreviewServerOptions
. The preview server defaults to the options in dev server forhost
,strictPort
,https
,cors
,proxy
, andopen
(I'm not sure about this last one), but not forport
. This would allow the user to define the preview port in vite.config.js instead of in the package.json script. It is more clear to see in theResolvedConfig
the resolved HTTP server options for the dev server and the preview server separately.This PR deprecates
printHttpServerUrls
because it doesn't work now thatconfig.server
andconfig.preview
are separate inResolvedConfig
. It still works fine for printing the URLs from the server, that is what the ecosystem could be using this function for (as the experimentalpreview
API was just exposed). Users ofcreateServer
andpreview
should useserver.printUrls()
. Maybe we should expose. The only place I see it being used is in Vitedge here https://github.com/frandiox/vitedge/blob/d64b6bc46988bf9df6896a32e499453d52476fbf/src/build/preview.js#L76, but this would continue to work.src/node/server/http.ts
has been moved tosrc/node/http.ts
as it is shared between the dev server and the preview serverWhat is the purpose of this pull request?