Skip to content

Commit

Permalink
fix for desktop apps not loading index.html after packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar committed Feb 19, 2020
1 parent 6d757c0 commit 8947b2c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const { app, BrowserWindow, Menu } = require("electron")
const path = require("path")
const menuTemplate = require("./menu-template")
const { format: formatUrl } = require("url")

function createWindow() {
console.log("Creating window...")
Expand All @@ -23,7 +24,13 @@ function createWindow() {
if (process.env.USE_DEV_SERVER) {
mainWindow.loadURL("http://localhost:6001")
} else {
mainWindow.loadFile(`${process.cwd()}/build/index.html`)
mainWindow.loadURL(
formatUrl({
pathname: path.join(__dirname, "../build", "index.html"),
protocol: "file",
slashes: true
})
)
}

// Open the DevTools.
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"build:babel": "cross-env NODE_ENV=production babel ./src --out-dir=./lib && cp ./package.json ./lib/package.json",
"build:web": "react-scripts build",
"build:desktop": "cross-env REACT_APP_DESKTOP=true PUBLIC_URL=./ react-scripts build && electron-builder build && cp ./desktop/entitlements.mac.plist ./build/entitlements.mac.plist",
"start:desktop": "USE_DEV_SERVER=yes electron ./desktop",
"start:desktop:dev": "USE_DEV_SERVER=yes electron ./desktop",
"start:desktop": "electron ./desktop",
"release:lib": "npm run build && cd lib && npm publish",
"release:desktop": "npm run build:desktop && electron-builder --mac --windows --linux --publish always",
"release": "npm run release:desktop",
Expand Down Expand Up @@ -86,6 +87,10 @@
],
"category": "Development"
},
"extends": null
"extends": null,
"files": [
"**/*",
"build/"
]
}
}

0 comments on commit 8947b2c

Please sign in to comment.