Feat/gdoc bundle#464
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Google Docs add-on sidebar to load the React bundle from an externally hosted URL (instead of inlining a large script), and wires the build/deploy pipeline to serve that bundle from the frontend container.
Changes:
- Update
google-docs-addon/sidebar.htmlto choose dev vs prod bundle base URL using the active document title (via Apps Script). - Add
getDocumentName()in Apps Script (Code.gs) and allowlisted URL fetching inappsscript.json. - Build and serve the Google Docs bundle (
dist-gdocs) from the frontend nginx container and introduce a Google-Docs-specific backend URL define.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| google-docs-addon/sidebar.html | Loads CSS/JS bundle from dev/prod base URL; adds a bridge method for doc title lookup. |
| google-docs-addon/Code.gs | Adds getDocumentName() for the sidebar to detect dev mode. |
| google-docs-addon/appsscript.json | Adds urlFetchWhitelist entry for published add-on URL fetches. |
| frontend/webpack.google-docs.config.js | Injects GDOCS_BACKEND_URL at build time for Google Docs bundle. |
| frontend/src/api/index.ts | Updates Google Docs backend URL resolution to prefer build-time GDOCS_BACKEND_URL. |
| frontend/Dockerfile | Builds the Google Docs bundle and serves it under /gdocs in nginx. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+214
to
+218
| s.onerror = function () { | ||
| document.getElementById('root').innerHTML = | ||
| '<div class="error-container"><h3>Could not load Writing Tools</h3>' + | ||
| '<p>Failed to load the app from <code>' + base + '</code>.</p></div>'; | ||
| }; |
Comment on lines
29
to
+33
| if (script?.src) { | ||
| return `${new URL(script.src).origin}/api`; | ||
| } | ||
| // Fallback to the dev server's default origin if currentScript is unavailable. | ||
| return 'http://localhost:3001/api'; | ||
| // No script src to read (e.g. inlined bundle): fall back to a relative /api. | ||
| return '/api'; |
Comment on lines
+60
to
+63
| // Backend origin for the Google Docs sidebar. Empty in dev (the sidebar | ||
| // reaches the backend through this dev server's /api proxy); in prod the | ||
| // bundle is inlined into the Apps Script HTML, so bake in the deployed | ||
| // backend that the sidebar calls directly. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apps Script won't execute a ~1.5MB inline <script>, so have to load it from an external URL instead:
published Workspace add-ons)