From 427ff959db05527b368158084c55263ebab9e37f Mon Sep 17 00:00:00 2001 From: hacker112 Date: Mon, 5 Feb 2018 11:13:41 +0100 Subject: [PATCH] fix: Make sure that index.html can be found in paths with hashtag (#20) --- src/main/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/index.js b/src/main/index.js index e332428..e9d4a36 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -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()