Last active
August 22, 2019 13:46
-
-
Save coenraadhuman/1f219c7e5c1de60dd3202bd6ffbc91c4 to your computer and use it in GitHub Desktop.
Using Angular and Firebase Project with Electron App Workaround
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('./server'); | |
const { app, BrowserWindow } = require('electron') | |
let win; | |
function createWindow () { | |
// Create the browser window. | |
win = new BrowserWindow({ | |
width: 1200, | |
height: 720, | |
backgroundColor: '#ffffff', | |
icon: `http://localhost:3007/assets/favicon.ico` | |
}); | |
// clear web contents for testing | |
// win.webContents.session.clearCache(function(){ | |
// console.log('Cache Cleared!') | |
// }); | |
// win.webContents.session.clearStorageData(function(){ | |
// console.log('Storage Cleared!'); | |
// }); | |
win.loadURL(`http://localhost:3007`) | |
// uncomment below to open the DevTools. | |
// win.webContents.openDevTools() | |
// Event when the window is closed. | |
win.on('closed', function () { | |
win = null | |
}) | |
} | |
// Create window on electron intialization | |
app.on('ready', createWindow) | |
// Quit when all windows are closed. | |
app.on('window-all-closed', function () { | |
// On macOS specific close process | |
if (process.platform !== 'darwin') { | |
app.quit() | |
} | |
}) | |
app.on('activate', function () { | |
// macOS specific close process | |
if (win === null) { | |
createWindow() | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var http = require('http'); | |
var path = require('path'); | |
var appServer = express(); | |
appServer.use(express.static(path.join(__dirname, 'dist','penguin-messenger'))); // this determines the destination of served files | |
appServer.get('*', (req, res) => { | |
res.sendFile(__dirname + 'index.html'); | |
}); | |
http.createServer(appServer).listen(3007, function() { | |
console.log('Express server listening on port'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Initially found at:
Some useful links on getting started with Electron Apps: