Comments (17)
Yes. Others are asking (#32) and I'm working on a fully functioning version to include with this repo.
For now if you want the quick version so you can work locally, you need to install webpack-dev-server, which is what Create React App uses. Just run these commands:
- Install webpack dev server:
npm i -D webpack-dev-server
- Run webpack dev server:
npx webpack-dev-server --mode development --port 8080
- Open the page you're working on in the browser: http://localhost:8080/about.html
Couple of notes:
- Hot reloading should work. Just save your code changes and the page will reload.
- As you said, you'll need to mock any server responses. If you actually try to call the server you'll get a
google is not defined
error in the browser. http://localhost:8080/main.html in my example app won't load since it calls the server, butabout.html
. - Your page will take up the full screen, so you may want to wrap it in a container that's the size of your dialog/sidebar to see what it will actually look like.
I have a solution on how to run your local code inside an actual google dialog/sidebar, and call the actual server functions. It works really well, it's just pretty complicated and needs cleaning up. Will post here when I have a version you can try out.
from react-google-apps-script.
FANTASTIC! :) Thanks so much for the work you're doing.
from react-google-apps-script.
Hey @nikola3244 thanks for this. Yes, think you're right. Haven't tried your steps yet but for now can you try putting the -impl
files in .claspignore
?
Something like this (don't know exact syntax off hand but you can reference https://github.com/google/clasp#ignore-file-claspignore if needed):
*-impl.html
**/*-impl.html
from react-google-apps-script.
Hi @enuchi , curious to know about the solution you are using to run locally. Is it a mock using gas-mock-globals or similar? or does it literally run actual App Script server code on local?
from react-google-apps-script.
@enuchi You rock! It works perfectly
Just noticed that main.js
is also excluded from pushing, so total size for pushing is now just 53.5KB (with the example files in my previous reply), and it appears to be working correctly, i.e. edits are instantly reflected in the addon.
from react-google-apps-script.
Yup, Material UI is a big library so makes sense not to import the whole thing if your bundles are still small.
Thanks for the PR, it's merged.
from react-google-apps-script.
Hi @enuchi , finally local dev is working on my new setup!! Thanks a ton! claspignore did the trick.
from react-google-apps-script.
Hi @jedgrant @kickbox , wanted to let you know that I've done a major update for the repo with support for local development. The development setup allows you to actually run your app locally and see it inside the google dialog window, while being able to access server code. It supports hot reloading for the react app. This should be a MUCH better development experience. If you get a chance please let me know if the new setup works for you.
from react-google-apps-script.
Hi @enuchi , I just upgraded my project setup to the latest version of this repo to test live local development.
-
Everything works as intended in Production mode.
-
However in Development mode
2.1. I am not able to push code. Push takes very a long time and starts printing parts of the code in terminal, then clasp finally fails with this error. This issue existed even before upgrading to the latest version of this repo. I dont mind this error now.
However after changingmode
toproduction
insideclientConfig
inwebpack.config.js
, this error disappears.2.2. The pressing issue is, I am unable to call server functions like this
serverFunctions.getSheetNames()
from frontend. I get the following error:Uncaught TypeError: ew.getSheetNames is not a function
. I checked the envrionment setup in webpack.config multiple times and everything seems fine.
Could you please point me in the right direction to resolve 2.2, I am stuck and really want to work with the live local development mode.
from react-google-apps-script.
Hi @kickbox, there were a lot of changes in the latest version. If you start with a fresh clone are you able to get the development mode working?
from react-google-apps-script.
Hey, for 2.1 that @kickbox mentioned, the problem is with the file size: for some reason the development build creates huge files and then tries to push them to Google which fails (as an example, the project that I'm working on has just two main files with several components and is about 40MB when compiled in development mode (npm run start
), while production mode (npm run deploy
) compiles it to just 0.9MB). That does not happen with a fresh repo clone.
@enuchi Funny thing is, the larger code can work if npm run start
is done with a smaller codebase and then the code is added locally without running npm run start
again, so that makes me think that there is a bug with compiling "large" codebases. ("large" is in quotes because they are not that large at all). I.e. I've cloned the fresh repo, did npm run start
, total size of dist/
is 0.3MB (I've also added all of the node dependencies required for the following jsx file). I've then added a simple static jsx file from the project I'm working on, and the changes successfully appeared in the addon. I've then stopped the server, ran npm run start
again, and the size of dist/
jumped to 25MB and clasp couldn't push it to Google. The biggest files are main.js
with 12.5MB and the offending -impl.html
with 12.5MB. The rest of the files are only 289KB total.
Just to give feedback for 2.2 as well: Server functions have been working perfectly for me, both in development and production.
from react-google-apps-script.
Hey @nikola3244, thanks for the details. If you have a public repo you can share would be happy to take a look. Or can you provide more info on the files you added or steps to reproduce? If you are adding external packages, the size can get large because all packages are bundled into one file -- -impl.html
in production and the regular .html
file in development. In development there is no minification so I can see that contributing to the large bundle. Which packages are you adding, if any?
from react-google-apps-script.
Hey @enuchi thanks for the quick reply, I unfortunately cannot share the project, company policies, but I am very willing to help with this issue, since development is not as fast as with live view.
The packages that are being added (to regular deps, not devDeps):
"@date-io/date-fns": "^1.3.13",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@material-ui/pickers": "^3.2.10",
"date-fns": "^2.16.0",
Steps to reproduce:
- Clone and setup the repo from scratch
- Add the packages mentioned above
- Unzip the test-page.zip in
src/client/test-page/
- Define the new page in
/webpack.config.js
+ menu in/src/server/ui.js
- Run
npm run start
, and see thedist/
size jump to 25MB
That all seems normal, right? File size goes up since it's not minified etc, but try this now:
- Clone and setup the repo from scratch
- Add the packages mentioned above
- Run
npm run start
without editing or adding anything - Do not stop the server
- Replace the contents of files in
/client/sidebar-about-page
with the files from test-page.zip from above - Go back to the open sheet tab, and see the new changes
That makes me think that all of the extra code is not needed to be pushed to Google for it to work, since new changes work even with the initial, small, /dist
directory. I don't really know how it all works with the live view, but can it be configured so just the server side functions + the web server related code is pushed while all of the compiled stuff is served from local during development?
I assume that this is what already gets pushed with the second scenario from above: server side functions + web server viewer + compiled example sidebar/dialog pages = small file size, with all new big changes are being served locally
from react-google-apps-script.
Great! I will open a PR soon to add the -impl files to .claspignore
, unless you would like to contribute it.
Also, just a note that the way this package works is by bundling everything into a single file. For large external packages this can add a lot in size to the overall bundle, even when minified in production. A better way is to load packages from a CDN, which will reduce the size of the file significantly, and also allow your users' browser to cache the package.
Using a CDN for your packages is not so straightforward, so that's why I added the working bootstrap example, added some instructions in the readme, and also some notes here in the webpack config:
React-Google-Apps-Script/webpack.config.js
Lines 143 to 176 in ad59879
from react-google-apps-script.
Thanks! I've created the PR.
The CDN suggestion is a good one, thanks, but I haven't went down that rabbit hole because of the warnings on Material UI's official site, which seemed reasonable, at least for this package: https://material-ui.com/getting-started/installation/#cdn
Also, I wasn't sure how my IDE (PhpStorm) would handle code suggestions etc if I haven't used a "native" Node package.
from react-google-apps-script.
@kickbox are you still having any issues with local development?
from react-google-apps-script.
Great. I'll close this issue then.
from react-google-apps-script.
Related Issues (20)
- infinity cycle refresh/reload by dev server when change the code HOT 2
- Menu Not Appearing HOT 7
- Creative ideas to enhance performance? EG getting Access Token into React App HOT 1
- Can we migrate to vite? HOT 4
- White (blank) sidebar in Chrome when using Station wallet Chrome extension HOT 12
- How to use shadcn/ui HOT 1
- Issue: app is not loaded when I deploy, but does work with HMR HOT 2
- I want to use fast refresh without https
- How to deploy a google workspace addon using this? HOT 6
- Is it possible to pass initial state to React root component? HOT 3
- Uncaught ReferenceError: react is not defined HOT 1
- Typescript support for custom functions HOT 14
- Seeing "Running script" with "Cancel" and "Dismiss" instead of "Working" when executing opening the sidebar HOT 2
- Support for NextJs HOT 4
- Uncaught ReferenceError: emotionReact is not defined at 9291 (userCodeAppPanel:2:53729) HOT 5
- JSdocs Autocomplete not working as expected HOT 9
- ReferenceError: TextEncoder is not defined : how to diagnose a solution HOT 3
- TypeScript support for TableCell.setBold() TableCell.setFontSize() HOT 1
- Solution for webapp react-router sync with google.script.history (Client-side API) HOT 3
- How to expose an Appscript ServerFunction to the user for attaching as a script? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-google-apps-script.