mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Support GRIST_INCLUDE_CUSTOM_SCRIPT_URL for custom scripts, specifically for rapid prototyping support
Test Plan: Tested manually on localhost Reviewers: paulfitz, georgegevoian Reviewed By: paulfitz, georgegevoian Subscribers: paulfitz, georgegevoian Differential Revision: https://phab.getgrist.com/D4186
This commit is contained in:
@@ -116,6 +116,12 @@ export function makeSendAppPage(opts: {
|
||||
baseDomain?: string
|
||||
}) {
|
||||
const {server, staticDir, tag, testLogin} = opts;
|
||||
|
||||
// If env var GRIST_INCLUDE_CUSTOM_SCRIPT_URL is set, load it in a <script> tag on all app pages.
|
||||
const customScriptUrl = process.env.GRIST_INCLUDE_CUSTOM_SCRIPT_URL;
|
||||
const insertCustomScript: string = customScriptUrl ?
|
||||
`<script src="${customScriptUrl}" crossorigin="anonymous"></script>` : '';
|
||||
|
||||
return async (req: express.Request, resp: express.Response, options: ISendAppPageOptions) => {
|
||||
const config = makeGristConfig({
|
||||
homeUrl: !isSingleUserMode() ? server.getHomeUrl(req) : null,
|
||||
@@ -153,6 +159,7 @@ export function makeSendAppPage(opts: {
|
||||
.replace("<!-- INSERT BASE -->", `<base href="${staticBaseUrl}">` + tagManagerSnippet)
|
||||
.replace("<!-- INSERT LOCALE -->", preloads)
|
||||
.replace("<!-- INSERT CUSTOM -->", customHeadHtmlSnippet)
|
||||
.replace("<!-- INSERT CUSTOM SCRIPT -->", insertCustomScript)
|
||||
.replace(
|
||||
"<!-- INSERT CONFIG -->",
|
||||
`<script>window.gristConfig = ${jsesc(config, {isScriptContext: true, json: true})};</script>`
|
||||
|
||||
Reference in New Issue
Block a user