fixed webpack config bug

remembered that .env exists.
This commit is contained in:
Rekai Musuka 2019-04-01 12:50:15 -05:00
parent 86eb20d584
commit 728a701533
3 changed files with 4 additions and 5 deletions

View File

@ -9,6 +9,7 @@
"recommendations": [ "recommendations": [
"esbenp.prettier-vscode", "esbenp.prettier-vscode",
"dbaeumer.vscode-eslint", "dbaeumer.vscode-eslint",
"mikestead.dotenv"
] ]
} }
} }

View File

@ -7,7 +7,7 @@ let win;
function createWindow() { 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. 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'); else win.loadFile('./build/index.html');
win.webContents.openDevTools(); win.webContents.openDevTools();

View File

@ -2,14 +2,12 @@ require('dotenv').config();
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const absolutePath = path.resolve(__dirname, 'build');
module.exports = { module.exports = {
mode: process.env.NODE_ENV, mode: process.env.NODE_ENV,
entry: ['@babel/polyfill', './src/renderer.js'], entry: ['@babel/polyfill', './src/renderer.js'],
output: { output: {
path: absolutePath, path: path.resolve(__dirname, 'build'),
filename: 'bundle.js' filename: 'bundle.js'
}, },
module: { module: {
@ -39,7 +37,7 @@ module.exports = {
devtool: 'inline-source-map', devtool: 'inline-source-map',
target: 'electron-renderer', target: 'electron-renderer',
devServer: { devServer: {
contentBase: absolutePath, contentBase: path.join(__dirname, 'build'),
compress: true, compress: true,
port: process.env.PORT port: process.env.PORT
} }