diff --git a/desktop/app/src/electron/initializeElectron.tsx b/desktop/app/src/electron/initializeElectron.tsx index c968afc83..114343638 100644 --- a/desktop/app/src/electron/initializeElectron.tsx +++ b/desktop/app/src/electron/initializeElectron.tsx @@ -180,6 +180,12 @@ export function initializeElectron( async requirePlugin(path) { return (window as any).electronRequire(path); }, + getStaticResourceUrl(relativePath): string { + return ( + 'file://' + + path.resolve(flipperServerConfig.paths.staticPath, relativePath) + ); + }, } as RenderHost; setupMenuBar(); diff --git a/desktop/flipper-ui-browser/src/initializeRenderHost.tsx b/desktop/flipper-ui-browser/src/initializeRenderHost.tsx index 6bdc26656..8751e7932 100644 --- a/desktop/flipper-ui-browser/src/initializeRenderHost.tsx +++ b/desktop/flipper-ui-browser/src/initializeRenderHost.tsx @@ -70,6 +70,10 @@ export function initializeRenderHost( // eslint-disable-next-line no-eval return eval(source); }, + getStaticResourceUrl(path): string { + // the 'static' folder is mounted as static middleware in Express at the root + return '/' + path; + }, } as RenderHost; } diff --git a/desktop/flipper-ui-core/src/RenderHost.tsx b/desktop/flipper-ui-core/src/RenderHost.tsx index fd84dec1c..0364f1ff0 100644 --- a/desktop/flipper-ui-core/src/RenderHost.tsx +++ b/desktop/flipper-ui-core/src/RenderHost.tsx @@ -97,6 +97,7 @@ export interface RenderHost { flipperServer: FlipperServer; serverConfig: FlipperServerConfig; requirePlugin(path: string): Promise; + getStaticResourceUrl(relativePath: string): string; } export function getRenderHostInstance(): RenderHost { diff --git a/desktop/scripts/jest-setup-after.ts b/desktop/scripts/jest-setup-after.ts index 9bd4c6f6d..57f4b70e1 100644 --- a/desktop/scripts/jest-setup-after.ts +++ b/desktop/scripts/jest-setup-after.ts @@ -187,5 +187,8 @@ function createStubRenderHost(): RenderHost { async requirePlugin(path: string) { return require(path); }, + getStaticResourceUrl(relativePath): string { + return 'file://' + resolve(rootPath, 'static', relativePath); + }, }; }