Skip to content

Commit 6cf2793

Browse files
Got electron to start along with sqlite3
1 parent 4d8fd24 commit 6cf2793

File tree

4 files changed

+243
-19
lines changed

4 files changed

+243
-19
lines changed

electron/main.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { app, BrowserWindow, ipcMain } from 'electron'
2+
import sqlite3 from 'sqlite3'
3+
4+
const database = new sqlite3.Database('./public/db.sqlite3', (err) => {
5+
if (err) console.error('Database opening error: ', err);
6+
});
27

38
let mainWindow: BrowserWindow | null
49

@@ -17,7 +22,7 @@ function createWindow () {
1722
height: 700,
1823
backgroundColor: '#191622',
1924
webPreferences: {
20-
nodeIntegration: false,
25+
nodeIntegration: true,
2126
contextIsolation: true,
2227
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY
2328
}

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"make": "electron-forge make",
1111
"release": "electron-forge publish",
1212
"lint": "eslint . --ext js,ts",
13-
"test": "jest"
13+
"test": "jest",
14+
"rebuild-sqlite3": "electron-rebuild -f -w sqlite3"
1415
},
1516
"keywords": [],
1617
"license": "MIT",
@@ -52,6 +53,7 @@
5253
"babel-loader": "8.2.2",
5354
"cross-env": "7.0.3",
5455
"electron": "13.1.2",
56+
"electron-rebuild": "^3.2.9",
5557
"eslint": "7.29.0",
5658
"eslint-config-prettier": "8.3.0",
5759
"eslint-config-standard": "16.0.3",
@@ -67,7 +69,11 @@
6769
"prettier": "2.3.1",
6870
"ts-jest": "27.0.3",
6971
"typescript": "4.9.5",
70-
"wait-on": "5.3.0"
72+
"wait-on": "5.3.0",
73+
"webpack-node-externals": "^3.0.0"
74+
},
75+
"resolutions": {
76+
"sqlite3/node-addon-api": "3.1.0"
7177
},
7278
"config": {
7379
"forge": {

webpack/main.webpack.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
const nodeExternals = require('webpack-node-externals');
2+
13
module.exports = {
24
resolve: {
35
extensions: ['.ts', '.js']
46
},
57
entry: './electron/main.ts',
68
module: {
79
rules: require('./rules.webpack'),
8-
}
10+
},
11+
externals: [nodeExternals()],
912
}

0 commit comments

Comments
 (0)