Skip to content

Feat/gdoc bundle#464

Merged
kcarnold merged 5 commits into
mainfrom
feat/gdoc-bundle
Jun 12, 2026
Merged

Feat/gdoc bundle#464
kcarnold merged 5 commits into
mainfrom
feat/gdoc-bundle

Conversation

@MaryChen68

Copy link
Copy Markdown
Contributor

Apps Script won't execute a ~1.5MB inline <script>, so have to load it from an external URL instead:

  • frontend/Dockerfile: also run build:google-docs and serve the output at/gdocs, so the bundle is reachable at /gdocs/google-docs.bundle.js
  • sidebar.html: load bundle/css from an external base. Dev vs prod is chosen by the document title -- a title containing [dev] loads from the localhost dev server (live reload); everything else loads the production bundle.
  • Code.gs: add getDocumentName() so the sidebar can read the doc title
  • appsscript.json: add urlFetchWhitelist (required for UrlFetchApp in
    published Workspace add-ons)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.html to 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 in appsscript.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 thread frontend/src/api/index.ts Outdated
Comment thread frontend/src/api/index.ts
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 thread frontend/webpack.google-docs.config.js Outdated
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.
@kcarnold kcarnold merged commit d71b909 into main Jun 12, 2026
8 checks passed
@kcarnold kcarnold deleted the feat/gdoc-bundle branch June 12, 2026 20:23
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