enuchi / React-Google-Apps-Script

This is your boilerplate project for developing React apps inside Google Sheets, Docs, Forms and Slides projects. It's perfect for personal projects and for publishing complex add-ons in the Google Workspace Marketplace.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How is GAS live-reload implemented?

eakl opened this issue Β· comments

commented

Thank you for this boilerplate. Looking at your code, I have leant a lot πŸ™

I am trying to create a simple version of this boilerplate with Svelte and vite/esbuild. One part I don't quite understand is how you managed to implement the live reload between your local dev server and Google's server.

I have created the minimal dev app wrapping an iframe that points to https://localhost:5173

<iframe src='https://localhost:5173' />

And then run the dev server with vite dev on HTTPS
Alternatively (because vite serves your app without writing anything to disk in dev mode) I have tried to build the app and serve the /build folder.

None of what I tried works. I don't see anything inside the iframe.

How is the dev app on Google server supposed to resolve https://localhost:5173 to your local dev server?

Can you share a repo with your sample app? Can try to help.

When you run vite dev and open https://localhost:5173 in a new tab do you see your app running at that exact url? The dev react app "wrapper" that you linked to just loads the iframe with localhost as the frame src as you describe. From what I remember you must serve on https with a self signed cert. I have some instructions in the readme on how to set those up for webpack but may need some tweaking to support your setup.

commented

Thank you @enuchi

This is basic setup with Vite https://github.com/eakl/gas-livereload

I am running vite dev server over HTTPS with a self signed certificate. I can see the iframe in the GAS sidebar but it doesn't show my local app.

I have read your readme Dev App Wrapper and GAS Webpack Dev Server but I'm probably missing something.

Live reload seems to work fine for me in your app. I was able to get it working:

vite.live.reload.mov

Make sure you are not using Brave browser or extensions or anything like that that would block iframes from loading content. What platform/browser are you using?

Also does vite dev server work correctly in its own tab using https?

commented

You got it right! I'm using Brave and indeed it was blocking the iframe.

I thought I missed something in my code but didn't expect it was coming from this. I would need to test future issues on different browsers.

Thanks a lot for your time and help!

OK glad this helped. Referencing #158 which gave me the idea.

I'll add some info about Brave to the README at some point since it's come up a couple times.