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

Handle Vite 5 types changes #254

Closed
wants to merge 2 commits into from
Closed

Handle Vite 5 types changes #254

wants to merge 2 commits into from

Conversation

bluwy
Copy link

@bluwy bluwy commented Oct 22, 2023

Vite 5 removes the https: boolean type and as it doesn't have much use by default. A plugin or manual configuration is always needed for https to actually work (e.g. certs). (vitejs/vite#14681)

This PR updates the types breaking change caused by it. It uses @ts-ignore so it works on both Vite 4 and 5. The as any is also needed so the config hook doesn't error by TS due to incorrect type returned by the function.


Extra notes unrelated to PR

It seems like before (Vite 4), users could do vite --https or https: true in vite.config.js to get the right certs generate by laravel-vite-plugin. In Vite 5, this isn't possible anymore except if https: {} in vite.config.js. Though it isn't quite exactly documented in the laravel docs.

Just want to note this in case you want to handle this differently in the future. For example, the detectTls could be used to enable https internally. Right now it doesn't due to the existing logic here:

vite-plugin/src/index.ts

Lines 163 to 166 in 7abca67

https: userConfig.server?.https === false ? false : {
...serverConfig.https,
...(userConfig.server?.https === true ? {} : userConfig.server?.https),
},

@gabrielrbarbosa
Copy link

#253

@SuperDJ SuperDJ mentioned this pull request Dec 5, 2023
@timacdonald timacdonald marked this pull request as draft December 10, 2023 23:25
@timacdonald
Copy link
Member

Really appreciate you sliding into our Laravel plugin, @bluwy, to help get us ready for Vite 5 ❤️

I've take the changes here and added them to our single PR to upgrade to Vite 5. I'll close this one off, but thank you so much.

We are also gonna drop Vite 4 support, so it should make things a little smoother with type changes.

@bluwy
Copy link
Author

bluwy commented Dec 13, 2023

No problem! 👍

@bluwy bluwy deleted the vite-5-types branch December 13, 2023 10:03
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