From 728a7015336df73d51099906563e6ad25c5bb578 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Mon, 1 Apr 2019 12:50:15 -0500 Subject: [PATCH] fixed webpack config bug remembered that .env exists. --- .vscode/melodii.code-workspace | 1 + main.js | 2 +- webpack.config.js | 6 ++---- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.vscode/melodii.code-workspace b/.vscode/melodii.code-workspace index 8c1b1a9..f8a1aae 100644 --- a/.vscode/melodii.code-workspace +++ b/.vscode/melodii.code-workspace @@ -9,6 +9,7 @@ "recommendations": [ "esbenp.prettier-vscode", "dbaeumer.vscode-eslint", + "mikestead.dotenv" ] } } \ No newline at end of file diff --git a/main.js b/main.js index c0bd3f7..4d96b87 100644 --- a/main.js +++ b/main.js @@ -7,7 +7,7 @@ let win; function createWindow() { win = new BrowserWindow({ width: 800, height: 600, frame: false, webPreferences: { webSecurity: false } }); //TODO: Please find a better solution for the love of god. - if (process.env.NODE_ENV) win.loadURL(`http://localhost:${process.env.PORT}`); + if (process.env.NODE_ENV === "development") win.loadURL(`http://localhost:${process.env.PORT}`); else win.loadFile('./build/index.html'); win.webContents.openDevTools(); diff --git a/webpack.config.js b/webpack.config.js index 7c0cc11..6318392 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,14 +2,12 @@ require('dotenv').config(); const path = require('path'); const webpack = require('webpack'); -const absolutePath = path.resolve(__dirname, 'build'); - module.exports = { mode: process.env.NODE_ENV, entry: ['@babel/polyfill', './src/renderer.js'], output: { - path: absolutePath, + path: path.resolve(__dirname, 'build'), filename: 'bundle.js' }, module: { @@ -39,7 +37,7 @@ module.exports = { devtool: 'inline-source-map', target: 'electron-renderer', devServer: { - contentBase: absolutePath, + contentBase: path.join(__dirname, 'build'), compress: true, port: process.env.PORT }