Skip to content

Commit 6e0c965

Browse files
committed
set up the elctron app stuff... it works :)
1 parent 1b9f175 commit 6e0c965

File tree

8 files changed

+2172
-640
lines changed

8 files changed

+2172
-640
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.rescriptsrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = [require.resolve('./.webpack.config.js')]

.webpack.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// define child rescript
2+
module.exports = config => {
3+
config.target = 'electron-renderer';
4+
return config;
5+
}

functions/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"logs": "firebase functions:log"
1111
},
1212
"engines": {
13-
"node": "10"
13+
"node": "12"
1414
},
1515
"dependencies": {
1616
"firebase-admin": "^8.6.0",

package.json

+43-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
"version": "1.0.0",
44
"description": "",
55
"keywords": [],
6-
"main": "src/index.js",
6+
"main": "public/electron.js",
7+
"homepage": "./",
78
"dependencies": {
89
"@emotion/core": "10.0.21",
910
"@testing-library/jest-dom": "4.1.2",
1011
"@testing-library/react": "9.3.0",
12+
"electron-is-dev": "^1.1.0",
1113
"firebase": "6.6.1",
1214
"firebase-tools": "7.6.1",
1315
"lodash": "4.17.15",
@@ -19,16 +21,51 @@
1921
"recharts": "1.8.3"
2022
},
2123
"devDependencies": {
22-
"typescript": "3.3.3"
24+
"@rescripts/cli": "^0.0.13",
25+
"@rescripts/rescript-env": "^0.0.11",
26+
"concurrently": "^5.0.0",
27+
"electron": "^7.1.1",
28+
"electron-builder": "^22.1.0",
29+
"typescript": "^3.7.2",
30+
"wait-on": "^3.3.0"
2331
},
2432
"scripts": {
2533
"install": "cd functions && yarn",
26-
"start": "react-scripts start",
27-
"build": "react-scripts build",
28-
"test": "react-scripts test --env=jsdom",
34+
"start": "rescripts start",
35+
"build": "rescripts build",
36+
"test": "rescripts test",
2937
"eject": "react-scripts eject",
38+
"postinstall": "electron-builder install-app-deps",
39+
"preelectron-pack": "yarn build",
40+
"electron-pack": "build -mw",
41+
"electron-dev": "concurrently \"BROWSER=none yarn start\" \"wait-on http://localhost:3000 && electron .\"",
3042
"firebase": "firebase",
3143
"deploy": "yarn firebase deploy"
3244
},
33-
"browserslist": [">0.2%", "not dead", "not ie <= 11", "not op_mini all"]
45+
"browserslist": [
46+
">0.2%",
47+
"not dead",
48+
"not ie <= 11",
49+
"not op_mini all"
50+
],
51+
"author": {
52+
"name": "Your Name",
53+
"email": "[email protected]",
54+
"url": "https://your-website.com"
55+
},
56+
"build": {
57+
"appId": "com.my-website.my-app",
58+
"productName": "MyApp",
59+
"copyright": "Copyright © 2019 ${author}",
60+
"mac": {
61+
"category": "public.app-category.utilities"
62+
},
63+
"files": [
64+
"build/**/*",
65+
"node_modules/**/*"
66+
],
67+
"directories": {
68+
"buildResources": "assets"
69+
}
70+
}
3471
}

public/electron.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const electron = require('electron');
2+
const app = electron.app;
3+
const BrowserWindow = electron.BrowserWindow;
4+
5+
const path = require('path');
6+
const isDev = require('electron-is-dev');
7+
8+
let mainWindow;
9+
10+
function createWindow() {
11+
mainWindow = new BrowserWindow({width: 900, height: 680, webPreferences: {
12+
nodeIntegration: true
13+
}});
14+
mainWindow.loadURL(isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, '../build/index.html')}`);
15+
if (isDev) {
16+
// Open the DevTools.
17+
//BrowserWindow.addDevToolsExtension('<location to your react chrome extension>');
18+
mainWindow.webContents.openDevTools();
19+
}
20+
mainWindow.on('closed', () => mainWindow = null);
21+
}
22+
23+
app.on('ready', createWindow);
24+
25+
app.on('window-all-closed', () => {
26+
if (process.platform !== 'darwin') {
27+
app.quit();
28+
}
29+
});
30+
31+
app.on('activate', () => {
32+
if (mainWindow === null) {
33+
createWindow();
34+
}
35+
});

src/style.css

+4-81
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,6 @@
1-
html,
2-
body,
3-
div,
4-
span,
5-
applet,
6-
object,
7-
iframe,
8-
h1,
9-
h2,
10-
h3,
11-
h4,
12-
h5,
13-
h6,
14-
p,
15-
blockquote,
16-
pre,
17-
a,
18-
abbr,
19-
acronym,
20-
address,
21-
big,
22-
cite,
23-
code,
24-
del,
25-
dfn,
26-
em,
27-
img,
28-
ins,
29-
kbd,
30-
q,
31-
s,
32-
samp,
33-
small,
34-
strike,
35-
strong,
36-
sub,
37-
sup,
38-
tt,
39-
var,
40-
b,
41-
u,
42-
i,
43-
center,
44-
dl,
45-
dt,
46-
dd,
47-
ol,
48-
ul,
49-
li,
50-
fieldset,
51-
form,
52-
label,
53-
legend,
54-
table,
55-
caption,
56-
tbody,
57-
tfoot,
58-
thead,
59-
tr,
60-
th,
61-
td,
62-
article,
63-
aside,
64-
canvas,
65-
details,
66-
embed,
67-
figure,
68-
figcaption,
69-
footer,
70-
header,
71-
hgroup,
72-
menu,
73-
nav,
74-
output,
75-
ruby,
76-
section,
77-
summary,
78-
time,
79-
mark,
80-
audio,
81-
video {
1+
body {
822
font-family: "Fira Sans", sans-serif;
3+
background: white;
834
}
5+
6+

0 commit comments

Comments
 (0)