Merge pull request #6 from cpvalente/fix/buildbuildbuild

thank you
This commit is contained in:
Carlos Valente
2021-06-03 13:01:05 +02:00
committed by GitHub
3 changed files with 20 additions and 10 deletions
+5 -5
View File
@@ -9,9 +9,9 @@ const {
const path = require('path'); const path = require('path');
const { electron } = require('process'); const { electron } = require('process');
(async () => { var env = process.env.NODE_ENV || 'prod';
const { nodeapp } = await import('./src/app.js');
})(); const { nodeapp } = import(path.join(__dirname, env=='prod' ? '../' : '', 'src/app.js'));
// Load Icons // Load Icons
// TODO: Icons appear pixelated // TODO: Icons appear pixelated
@@ -68,8 +68,8 @@ function createWindow() {
try { try {
// loaded = path.join(__dirname, '../client/build/index.html'); // loaded = path.join(__dirname, '../client/build/index.html');
// win.loadURL(`file://${loaded}`); // win.loadURL(`file://${loaded}`);
// win.loadURL('http://localhost:4001/editor'); win.loadURL('http://localhost:4001/editor');
win.loadURL(`file://${__dirname}/dist/index.html`); //win.loadURL(`file://${__dirname}/dist/index.html`);
} catch (error) { } catch (error) {
loaded = error; loaded = error;
} }
+10 -2
View File
@@ -29,14 +29,15 @@
"eslint-plugin-simple-import-sort": "^7.0.0" "eslint-plugin-simple-import-sort": "^7.0.0"
}, },
"scripts": { "scripts": {
"nodestart": "node app.js", "nodestart": "NODE_ENV=development node app.js",
"start": "electron .", "start": "NODE_ENV=development electron .",
"pack": "electron-builder --dir", "pack": "electron-builder --dir",
"dist": "electron-builder", "dist": "electron-builder",
"startall": "concurrently \"BROWSER=none yarn start\" \"wait-on http://localhost:3000 && electron .\"" "startall": "concurrently \"BROWSER=none yarn start\" \"wait-on http://localhost:3000 && electron .\""
}, },
"build": { "build": {
"appId": "your.id", "appId": "your.id",
"asar": false,
"mac": { "mac": {
"category": "your.app.category.type" "category": "your.app.category.type"
}, },
@@ -50,6 +51,13 @@
"filter": [ "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 __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); 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); const adapter = new JSONFile(file);
export const db = new Low(adapter); export const db = new Low(adapter);
@@ -66,10 +68,10 @@ app.use('/event', eventRouter);
app.use('/ontime', ontimeRouter); app.use('/ontime', ontimeRouter);
// serve react // 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) => { 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 // Implement route for errors