Electron env updates

This commit is contained in:
uonai 2020-08-01 13:25:24 -05:00
parent 39e244897a
commit 053a8bf11c
3 changed files with 32 additions and 15 deletions

View File

@ -3,6 +3,11 @@ const { app, BrowserWindow } = require("electron");
const path = require("path");
const fs = require("fs-extra");
// NOTE(colin): use NEXTJS Production build
process.env.NODE_ENV = "production";
// NOTE(colin): allow API connection
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
function bootServer() {
// TODO(colin): Spin up server on a child process
// const { fork } = require('child_process');
@ -51,7 +56,7 @@ app.whenReady().then(() => {
bootServer();
createWindow();
app.on("activate", function() {
app.on("activate", function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow();
@ -61,7 +66,7 @@ app.whenReady().then(() => {
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on("window-all-closed", function() {
app.on("window-all-closed", function () {
if (process.platform !== "darwin") app.quit();
});

View File

@ -1,18 +1,30 @@
require('@babel/register')({
const path = require("path");
const dirPath = path.join(__dirname);
require("@babel/register")({
presets: [
[require.resolve('@babel/preset-env')],
[require.resolve("@babel/preset-env")],
[
require.resolve('next/babel'),
require.resolve("next/babel"),
{
'preset-env': {},
'transform-runtime': {},
'styled-jsx': {},
'class-properties': {},
"preset-env": {},
"transform-runtime": {},
"styled-jsx": {},
"class-properties": {},
},
],
],
plugins: [[require.resolve('@babel/plugin-transform-runtime')]],
ignore: ['node_modules', '.next'],
plugins: [
[require.resolve("@babel/plugin-transform-runtime")],
[
require.resolve("babel-plugin-module-resolver"),
{
alias: {
"~": dirPath,
},
},
],
],
ignore: ["node_modules", ".next"],
});
module.exports = require('./server.js');
module.exports = require("./server.js");

View File

@ -10,9 +10,9 @@
"build": "NODE_ENV=production next build",
"build-electron": "NODE_ENV=production next build",
"build-system": "rollup -c",
"electron": "electron ./electron/main.js ",
"electron-pack": "electron-builder --dir",
"electron-dist": "electron-builder",
"electron": "NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_ENV=production electron ./electron/main.js ",
"electron-pack": "NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_ENV=production electron-builder --dir",
"electron-dist": "NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_ENV=production electron-builder",
"scripts": "NODE_TLS_REJECT_UNAUTHORIZED=0 node ./scripts",
"www-setup-database": "NODE_TLS_REJECT_UNAUTHORIZED=0 node ./scripts setup-database",
"www-seed-database": "NODE_TLS_REJECT_UNAUTHORIZED=0 node ./scripts seed-database",