diff --git a/server/main.js b/server/main.js index 77ca17e32..b84782e53 100644 --- a/server/main.js +++ b/server/main.js @@ -9,9 +9,9 @@ const { const path = require('path'); const { electron } = require('process'); -(async () => { - const { nodeapp } = await import('./src/app.js'); -})(); +var env = process.env.NODE_ENV || 'prod'; + +const { nodeapp } = import(path.join(__dirname, env=='prod' ? '../' : '', 'src/app.js')); // Load Icons // TODO: Icons appear pixelated @@ -68,8 +68,8 @@ function createWindow() { try { // loaded = path.join(__dirname, '../client/build/index.html'); // win.loadURL(`file://${loaded}`); - // win.loadURL('http://localhost:4001/editor'); - win.loadURL(`file://${__dirname}/dist/index.html`); + win.loadURL('http://localhost:4001/editor'); + //win.loadURL(`file://${__dirname}/dist/index.html`); } catch (error) { loaded = error; } diff --git a/server/package.json b/server/package.json index 0d1bfbd36..6df5fd0cb 100644 --- a/server/package.json +++ b/server/package.json @@ -29,14 +29,15 @@ "eslint-plugin-simple-import-sort": "^7.0.0" }, "scripts": { - "nodestart": "node app.js", - "start": "electron .", + "nodestart": "NODE_ENV=development node app.js", + "start": "NODE_ENV=development electron .", "pack": "electron-builder --dir", "dist": "electron-builder", "startall": "concurrently \"BROWSER=none yarn start\" \"wait-on http://localhost:3000 && electron .\"" }, "build": { "appId": "your.id", + "asar": false, "mac": { "category": "your.app.category.type" }, @@ -50,6 +51,13 @@ "filter": [ "**/*" ] + }, + { + "from": "src", + "to": "resources/src", + "filter": [ + "**/*" + ] } ] }, diff --git a/server/src/app.js b/server/src/app.js index 2898c0c7e..abe8ec960 100644 --- a/server/src/app.js +++ b/server/src/app.js @@ -10,7 +10,9 @@ import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); -const file = join('data/', config.database.filename); +var env = process.env.NODE_ENV || 'prod'; + +const file = join(__dirname, 'data/', config.database.filename); const adapter = new JSONFile(file); export const db = new Low(adapter); @@ -66,10 +68,10 @@ app.use('/event', eventRouter); app.use('/ontime', ontimeRouter); // serve react -app.use(express.static(path.join(__dirname, '../../client/build'))); +app.use(express.static(path.join(__dirname, env == 'prod' ? '../' : '../../', 'client/build'))); app.get('*', (req, res) => { - res.sendFile(path.resolve(__dirname, '../../client', 'build', 'index.html')); + res.sendFile(path.resolve(__dirname, env == 'prod' ? '../' : '../../', 'client', 'build', 'index.html')); }); // Implement route for errors