Skip to content

Commit 0259505

Browse files
committed
refactor: context isolation via preload script
Signed-off-by: Adam Setch <[email protected]>
1 parent 42ea62b commit 0259505

File tree

6 files changed

+8
-10
lines changed

6 files changed

+8
-10
lines changed

config/webpack.config.main.base.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ const configuration: webpack.Configuration = {
1212

1313
target: 'electron-main',
1414

15-
entry: [path.join(webpackPaths.srcMainPath, 'main.ts')],
15+
entry: {
16+
main: path.join(webpackPaths.srcMainPath, 'main.ts'),
17+
preload: path.join(webpackPaths.srcMainPath, 'preload.ts'),
18+
},
1619

1720
output: {
1821
path: webpackPaths.buildPath,

config/webpack.config.preload.base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const configuration: webpack.Configuration = {
1010

1111
mode: 'development',
1212

13-
target: 'electron-main',
13+
target: 'electron-preload',
1414

1515
entry: [path.join(webpackPaths.srcMainPath, 'preload.ts')],
1616

config/webpack.config.renderer.base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const configuration: webpack.Configuration = {
1515

1616
mode: 'development',
1717

18-
target: 'electron-renderer',
18+
target: ['web', 'electron-renderer'],
1919

2020
entry: [path.join(webpackPaths.srcRendererPath, 'index.tsx')],
2121

src/main/main.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ const browserWindowOpts = {
2121
minHeight: 400,
2222
resizable: false,
2323
skipTaskbar: true, // Hide the app from the Windows taskbar
24-
// TODO #700 refactor to use preload script with a context bridge
2524
webPreferences: {
2625
preload: path.join(__dirname, 'preload.js'),
27-
contextIsolation: true, // TODO change this
26+
contextIsolation: true,
2827
enableRemoteModule: false,
29-
nodeIntegration: false, // TODO change this
28+
nodeIntegration: false,
3029
},
3130
};
3231

src/main/preload.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import { Constants } from '../renderer/utils/constants';
55
import type { GitifyAPI } from './types';
66

77
const api: GitifyAPI = {
8-
// Define the global variable
9-
global: globalThis,
10-
118
openExternalLink: (url) =>
129
ipcRenderer.send(namespacedEvent('open-external-link'), url),
1310

src/main/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export interface GitifyAPI {
2-
global: typeof globalThis;
32
openExternalLink: (url: string) => void;
43
getAppVersion: () => Promise<string>;
54
encryptValue: (value: string) => Promise<string>;

0 commit comments

Comments
 (0)