diff --git a/packages/sanity/src/_internal/cli/server/renderDocument.tsx b/packages/sanity/src/_internal/cli/server/renderDocument.tsx index edafdb9f6b79..89359c5213e6 100644 --- a/packages/sanity/src/_internal/cli/server/renderDocument.tsx +++ b/packages/sanity/src/_internal/cli/server/renderDocument.tsx @@ -119,6 +119,18 @@ export function decorateIndexWithAutoGeneratedWarning(template: string): string return template.replace(/\n', + '\n', + ) +} + export function getPossibleDocumentComponentLocations(studioRootPath: string): string[] { return [path.join(studioRootPath, '_document.js'), path.join(studioRootPath, '_document.tsx')] } diff --git a/packages/sanity/src/_internal/cli/server/runtime.ts b/packages/sanity/src/_internal/cli/server/runtime.ts index 8c3bcf508d9b..26880dd418ca 100644 --- a/packages/sanity/src/_internal/cli/server/runtime.ts +++ b/packages/sanity/src/_internal/cli/server/runtime.ts @@ -7,6 +7,7 @@ import {debug as serverDebug} from './debug' import {getEntryModule} from './getEntryModule' import { decorateIndexWithAutoGeneratedWarning, + decorateIndexWithBridgeScript, getPossibleDocumentComponentLocations, renderDocument, } from './renderDocument' @@ -48,16 +49,18 @@ export async function writeSanityRuntime({ async function renderAndWriteDocument() { debug('Rendering document template') - const indexHtml = decorateIndexWithAutoGeneratedWarning( - await renderDocument({ - studioRootPath: cwd, - monorepo, - props: { - entryPath: `/${path.relative(cwd, path.join(runtimeDir, 'app.js'))}`, - basePath: basePath || '/', - }, - isCoreApp, - }), + const indexHtml = decorateIndexWithBridgeScript( + decorateIndexWithAutoGeneratedWarning( + await renderDocument({ + studioRootPath: cwd, + monorepo, + props: { + entryPath: `/${path.relative(cwd, path.join(runtimeDir, 'app.js'))}`, + basePath: basePath || '/', + }, + isCoreApp, + }), + ), ) debug('Writing index.html to runtime directory') diff --git a/packages/sanity/src/core/studio/Bridge.tsx b/packages/sanity/src/core/studio/Bridge.tsx deleted file mode 100644 index f3f31e957832..000000000000 --- a/packages/sanity/src/core/studio/Bridge.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import {useInsertionEffect} from 'react' - -const Bridge = () => { - useInsertionEffect(() => { - const src = 'https://core.sanity-cdn.com/bridge.js' - const script = document.createElement('script') - script.type = 'module' - script.async = true - script.src = src - - document.head.appendChild(script) - }, []) - - return null -} - -export {Bridge} diff --git a/packages/sanity/src/core/studio/Studio.tsx b/packages/sanity/src/core/studio/Studio.tsx index a370afca9cfa..475cc729cb9b 100644 --- a/packages/sanity/src/core/studio/Studio.tsx +++ b/packages/sanity/src/core/studio/Studio.tsx @@ -6,7 +6,6 @@ import {GlobalStyle} from './GlobalStyle' import {type RouterHistory} from './router' import {StudioLayout} from './StudioLayout' import {StudioProvider} from './StudioProvider' -import {Bridge} from './Bridge' /** * @hidden @@ -113,7 +112,6 @@ export function Studio(props: StudioProps): React.JSX.Element { unstable_history={unstable_history} unstable_noAuthBoundary={unstable_noAuthBoundary} > - {globalStyles && }