Skip to content

Instantly share code, notes, and snippets.

@mfcodeworks
Created September 11, 2019 07:55
Show Gist options
  • Save mfcodeworks/6f186ee74d0e15fc7ecca4d7241a8d82 to your computer and use it in GitHub Desktop.
Save mfcodeworks/6f186ee74d0e15fc7ecca4d7241a8d82 to your computer and use it in GitHub Desktop.
Electron Angular Configuration
const {app, BrowserWindow} = require('electron');
const url = require('url');
const path = require('path');
let mainWindow;
function createWindow() {
mainWindow = new BrowserWindow({
width: 1000,
height: 800,
webPreferences: {
nodeIntegration: true
},
icon: path.join(__dirname, `/dist/favicon.ico`),
});
mainWindow.loadURL(
url.format({
pathname: path.join(__dirname, `/dist/index.html`),
protocol: "file:",
slashes: true
})
);
// Open the DevTools.
mainWindow.webContents.openDevTools();
mainWindow.on('closed', function () {
mainWindow = null;
});
}
app.on('ready', createWindow)
app.on('window-all-closed', function() {
if (process.platform !== 'darwin') app.quit();
})
app.on('activate', function() {
if (mainWindow === null) createWindow();
});
//...
"scripts": {
//...
"electron:start": "ng build --base-href ./ && electron ."
},
"main": "index.js",
//...
//...
"target": "es5", // Only working fix currently, can revert to es2015 when electron allows loading
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment