@@ -11,6 +11,7 @@ import {APP_NAME, WEBSITE, COPYRIGHT_NOTICE, ACCENT_COLOR} from './brand';
11
11
import { OutdatedPackagerError } from '../common/errors' ;
12
12
import { darken } from './colors' ;
13
13
import { Adapter } from './adapter' ;
14
+ import electronPreloadJS from '!raw-loader!./electron-preload.js' ;
14
15
15
16
const PROGRESS_LOADED_SCRIPTS = 0.1 ;
16
17
@@ -435,7 +436,7 @@ cd "$(dirname "$0")"
435
436
// +-- resources
436
437
// +-- default_app.asar (we will delete this)
437
438
// +-- app (we will create this)
438
- // +-- index.html and the other project files (we will create this )
439
+ // +-- index.html, preload.js, and the other project files (we will create these )
439
440
// +-- LICENSES.chromium.html and everything else
440
441
441
442
// Electron macOS folder structure:
@@ -463,7 +464,7 @@ cd "$(dirname "$0")"
463
464
// +-- default_app.asar (we will delete this)
464
465
// +-- electron.icns (we will update this)
465
466
// +-- app (we will create this)
466
- // +-- index.html and the other project files (we will create this )
467
+ // +-- index.html, preload.js, and the other project files (we will create these )
467
468
// +-- LICENSES.chromium.html and other license files
468
469
469
470
const zip = new ( await getJSZip ( ) ) ;
@@ -512,6 +513,7 @@ cd "$(dirname "$0")"
512
513
const contentsPrefix = isMac ? `${ rootPrefix } ${ packageName } .app/Contents/` : rootPrefix ;
513
514
const resourcesPrefix = isMac ? `${ contentsPrefix } Resources/app/` : `${ contentsPrefix } resources/app/` ;
514
515
const electronMainName = 'electron-main.js' ;
516
+ const electronPreloadName = 'electron-preload.js' ;
515
517
const iconName = 'icon.png' ;
516
518
517
519
const icon = await Adapter . getAppIcon ( this . options . app . icon ) ;
@@ -558,6 +560,7 @@ const createWindow = (windowOptions) => {
558
560
sandbox: true,
559
561
contextIsolation: true,
560
562
nodeIntegration: false,
563
+ preload: path.resolve(__dirname, ${ JSON . stringify ( electronPreloadName ) } ),
561
564
},
562
565
show: true,
563
566
width: 480,
@@ -697,6 +700,7 @@ app.whenReady().then(() => {
697
700
});
698
701
` ;
699
702
zip . file ( `${ resourcesPrefix } ${ electronMainName } ` , mainJS ) ;
703
+ zip . file ( `${ resourcesPrefix } ${ electronPreloadName } ` , electronPreloadJS ) ;
700
704
701
705
for ( const [ path , data ] of Object . entries ( projectZip . files ) ) {
702
706
setFileFast ( zip , `${ resourcesPrefix } ${ path } ` , data ) ;
0 commit comments