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

Add support for secured sites and browsersync to vite #307

Merged
merged 12 commits into from
Apr 3, 2023
Merged

Add support for secured sites and browsersync to vite #307

merged 12 commits into from
Apr 3, 2023

Conversation

marcorieser
Copy link
Contributor

Changes proposed in this pull request:

  • Configure Vite to use valet ssl certificates
  • Add option to run BrowserSync on top of Vite which adds the ability to access local sites in the network

@robdekort
Copy link
Contributor

robdekort commented Mar 18, 2023

This looks cool. Love how it's optional. I'll give it a test run next Monday!

@marcorieser
Copy link
Contributor Author

I had BrowserSync running permanently yesterday. On the Mac I viewed the page via domain.test (valet and vite) and on the mobile via 192.168.178.93:3000 (Browsersync and vite). Everything worked fine in parallel. According to the documentation, they made sure that BrowserSync does not execute anything that Vite already does and it acts on Vite events.

@marcorieser
Copy link
Contributor Author

Maybe tinkering a bit more with the expose (valet share) approach could be a good alternative which does not add something on top. Not sure if i have time for that on monday.

@robdekort
Copy link
Contributor

Not sure what you're talking about but but you can make this a draft PR. Let me know when you want me to take a look!

@marcorieser marcorieser marked this pull request as draft March 19, 2023 15:19
@marcorieser
Copy link
Contributor Author

Not sure what you're talking about but but you can make this a draft PR. Let me know when you want me to take a look!

No worries 😁 I was talking about expose (https:/beyondcode/expose) which exposes local sites via secure tunnels (which then could be an alternative approach to Browsersync since that is available with valet anyway).

I experimented a bit yesterday but had no luck with sharing a non-https site trough expose (opened an issue on their repo). So I'd leave it at Browsersync for now. If we come up with something better in the future, we can remove Browsersync again.

I don't know if it makes sense to add the changes directly to the core, or if we'd rather create a section in the documentation for those who need it.

So, please have a look at it now.

@marcorieser marcorieser marked this pull request as ready for review March 20, 2023 07:26
@robdekort
Copy link
Contributor

Interesting. I had never heard of this tool. I just tried it and got it working. Then I tried it again with expose and (non https) I didn't get my styles and JS.

@robdekort
Copy link
Contributor

However this is a free and working solution that doesn't require any account or payment so I'm happy to merge in the browsersync changes. Do you think you can work this in so forms work? #222

@marcorieser
Copy link
Contributor Author

Interesting. I had never heard of this tool. I just tried it and got it working. Then I tried it again with expose and (non https) I didn't get my styles and JS.

expose is very nice!
the issues are that non-https sites get redirected to https which leads to browsers blocking the vite url... plus the vite dev url does not get replaced (which probably could be resolved by setting the vite host explicitly to the app url)

Do you think you can work this in so forms work? #222

Will have a look as soon as I hit the forms part in my current project

@marcorieser
Copy link
Contributor Author

marcorieser commented Apr 3, 2023

Got forms working via Browsersync on my iPhone in the network 🥳
But there are some changes to the TokenRefresh endpoint needed: studio1902/statamic-peak-tools#7

Do you think you can work this in so forms work? #222

Not sure if I truly get, what the intend for that PR was, but as far as I can tell he wanted Browsersync to open the valet domain instead of localhost or the IP (@delz-dev can you confirm?). You have exactly that behaviour by just using vite (npm run dev) which made Browsersync obsolete. We reintroduce Browsersync just for proxying our valet domain trough a port to our local network (npm run sync) and in that case opening the IP is desired behaviour because the valet domain can not be resolved in the network.

@marcorieser
Copy link
Contributor Author

One thing that came to my mind right now:
By default the following stuff is synced between the connected browsers/devices. Do you think this is nice by default (it can be disabled via the Browsersync UI in the browser) or should we disable everything by default?

Bildschirm­foto 2023-04-03 um 06 46 33

@robdekort
Copy link
Contributor

Cool stuff. I like the defaults btw. Seems good to me.

@robdekort robdekort merged commit 27eced8 into studio1902:main Apr 3, 2023
@marcorieser marcorieser deleted the optimize-vite branch April 3, 2023 12:56
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.

2 participants