fix: Make sure that index.html can be found in paths with hashtag (#20)

This commit is contained in:
hacker112 2018-02-05 11:13:41 +01:00 committed by Vladimir Krivosheev
parent 0f0ec413af
commit 427ff959db

View file

@ -1,6 +1,7 @@
'use strict'
import { app, BrowserWindow } from 'electron'
import { path } from 'path'
const isDevelopment = process.env.NODE_ENV !== 'production'
@ -12,12 +13,19 @@ function createMainWindow() {
// Construct new BrowserWindow
const window = new BrowserWindow()
// Path to index file in production environment
const productionIndexPath = url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file',
slashes: true
})
// Set url for `win`
// points to `webpack-dev-server` in development
// points to `index.html` in production
const url = isDevelopment
? `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`
: `file://${__dirname}/index.html`
: productionIndexPath
if (isDevelopment) {
window.webContents.openDevTools()