build fixed?

This commit is contained in:
Torbjørn Kvåle
2021-06-02 23:17:31 +02:00
parent 9e15ab6ea7
commit cdd2c58dc0
3 changed files with 20 additions and 10 deletions
+5 -5
View File
@@ -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;
}
+10 -2
View File
@@ -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": [
"**/*"
]
}
]
},
+5 -3
View File
@@ -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