Skip to content

Commit

Permalink
Document production and development differences
Browse files Browse the repository at this point in the history
  • Loading branch information
sleeyax committed Jun 15, 2024
1 parent e5161e2 commit 02152a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
16 changes: 8 additions & 8 deletions example/electron-forge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

## Usage

Development:
### Development

`npm start`
1. Update `package.json` entrypoint to `"main": ".vite/build/main.js",`
2. Run `npm start`

Package for production (use this to test whether asarmor is working correctly):
### Package for production

`npm run package`

To run the packaged application, execute the resulting binary. For example, on Linux:

`./out/my-app-linux-x64/electron-forge-example`
1. Update `package.json` entrypoint to `"main": ".vite/build/main.node",`
2. Run `npm run package`
3. Test the packaged application by executing the resulting binary.
For example (on Linux) run `/out/electron-forge-example-linux-x64/electron-forge-example `
20 changes: 11 additions & 9 deletions example/electron-forge/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@ const createWindow = async () => {
// and load the index.html of the app.
if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
mainWindow.loadURL(MAIN_WINDOW_VITE_DEV_SERVER_URL);
mainWindow.webContents.openDevTools();
} else {
mainWindow.loadFile(path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/index.html`));
await mainWindow.webContents.executeJavaScript(`!function () {
require('./renderer.node');
require('./assets/index.js');
}()`);
}

// Open the DevTools.
mainWindow.webContents.openDevTools();

await mainWindow.webContents.executeJavaScript(`!function () {
require('./renderer.node');
require('./assets/index.js');
}()`);
};

export default function bootstrap(k: Uint8Array) {
export default function bootstrap(k: Uint8Array | Array<number>) {
// sanity check
if (!Array.isArray(k) || k.length === 0) {
throw new Error('Failed to bootstrap application.');
Expand Down Expand Up @@ -66,5 +63,10 @@ export default function bootstrap(k: Uint8Array) {
});
}

// Bootstrap the application with an empty key when running in development mode.
if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
bootstrap([0]);
}

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.

0 comments on commit 02152a2

Please sign in to comment.