Skip to content

Commit b8e57e5

Browse files
committed
add basePathSync function
1 parent b812a2c commit b8e57e5

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

.github/workflows/tag-and-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
run: |
6363
sed -i 's/src="\/_expo/src="_expo/g' dist/index.html
6464
sed -i 's/href="\/_expo/href="_expo/g' dist/index.html
65-
find dist -type f -name '*.js' -exec sed -i 's|/_expo/static/js/web/|./|g' {} +
65+
find dist -type f -name '*.js' -exec sed -i 's|"/_expo/static/js/web/|window.electron.basePath + "_expo/static/js/web/|g' {} +
6666
6767
- name: Archive production artifacts
6868
uses: actions/upload-artifact@v3

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { createWindow } from './main/window';
1010
import './main/database';
1111
import './main/axios';
1212
import './main/print-external-url';
13+
import './main/basePath';
1314

1415
// enabled logging when in development
1516
if (process.env.NODE_ENV === 'development') {

src/main/basePath.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import path from 'path';
2+
3+
import { ipcMain } from 'electron';
4+
5+
ipcMain.on('getBasePathSync', (event) => {
6+
const basePath = `file://${path.join(process.resourcesPath, 'dist')}/`;
7+
event.returnValue = basePath; // Synchronously return the basePath
8+
});

src/preload.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';
22

33
/**
44
* Expose the basePath to the renderer process.
5+
*
6+
* @NOTE - This is a synchronous call, it will block the thread, but it's a quick call.
7+
* This is needed for the bundle splitting to work correctly.
58
*/
69
contextBridge.exposeInMainWorld('electron', {
7-
basePath: `file://${process.resourcesPath}/dist/`,
10+
basePath: ipcRenderer.sendSync('getBasePathSync'),
811
});
912

1013
// White-listed channels.

0 commit comments

Comments
 (0)