Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Commit

Permalink
Point electron at built files when we don't pass in a start url
Browse files Browse the repository at this point in the history
Also, pass in url for react app in dev
  • Loading branch information
AlMcKinlay committed Jul 6, 2020
1 parent 69b614a commit 508b291
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion electron/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ function createWindow() {
webPreferences: { nodeIntegration: true }
});

mainWindow.loadURL('http://localhost:3000');
const startUrl = process.env.ELECTRON_START_URL || url.format({
pathname: path.join(__dirname, '/../build/index.html'),
protocol: 'file:',
slashes: true
});
mainWindow.loadURL(startUrl);

// Open the DevTools.
if(process.argv.includes("dev")) {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"scripts": {
"dev": "concurrently 'npm:react' 'npm:electron:dev'",
"electron:dev": "electron . dev",
"electron:dev": "cross-env ELECTRON_START_URL=http://localhost:3000 electron . dev",
"react": "cross-env BROWSER=none react-scripts start",
"start": "react-scripts start",
"build": "react-scripts build",
Expand Down Expand Up @@ -63,5 +63,6 @@
"cross-env": "7.0.2",
"electron": "9.0.5",
"electron-builder": "22.7.0"
}
},
"homepage": "./"
}

0 comments on commit 508b291

Please sign in to comment.