Skip to content

Commit 7757bfd

Browse files
committed
revert(fix): update webpack to vite
upupdate the electron to latest and add vite.
1 parent b05e1f4 commit 7757bfd

30 files changed

+8255
-7242
lines changed

electron.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const { app, BrowserWindow } = require("electron");
2+
const path = require("path");
3+
4+
function createWindow() {
5+
const win = new BrowserWindow({
6+
width: 800,
7+
height: 600,
8+
webPreferences: {
9+
nodeIntegration: true,
10+
contextIsolation: false,
11+
},
12+
});
13+
14+
// Load the local development server if in dev mode
15+
if (process.env.NODE_ENV === "development") {
16+
win.loadURL("http://localhost:5173");
17+
} else {
18+
win.loadFile(path.join(__dirname, "dist", "index.html"));
19+
}
20+
}
21+
22+
app.whenReady().then(createWindow);
23+
24+
app.on("window-all-closed", () => {
25+
if (process.platform !== "darwin") {
26+
app.quit();
27+
}
28+
});
29+
30+
app.on("activate", () => {
31+
if (BrowserWindow.getAllWindows().length === 0) {
32+
createWindow();
33+
}
34+
});

index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>ITU OB Editor</title>
6+
</head>
7+
<body>
8+
<div id="root"></div>
9+
<script type="module" src="/src/renderer/index.tsx"></script>
10+
</body>
11+
</html>

main.webpack.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

package.json

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
"license": "MIT",
1515
"scripts": {
1616
"postinstall": "electron-builder install-app-deps",
17-
"dev": "electron-webpack dev",
18-
"compile": "electron-webpack",
19-
"clean": "rm -rf ./bundle ./dist",
20-
"dist": "cross-env DEBUG=electron-builder electron-builder",
17+
"dev": "vite",
18+
"electron-dev": "vite build && electron .",
19+
"build": "vite build",
20+
"preview": "vite preview",
21+
"compile": "vite build",
22+
"dist": "vite build && electron-builder",
23+
"dist:dir": "vite build && electron-builder --dir",
2124
"dist:win": "electron-builder -w",
2225
"dist:mac": "electron-builder -m",
2326
"pack": "electron-builder --dir",
@@ -34,15 +37,6 @@
3437
"browserslist": [
3538
"electron 8.0"
3639
],
37-
"electronWebpack": {
38-
"staticSourceDirectory": "src/static",
39-
"main": {
40-
"webpackConfig": "main.webpack.js"
41-
},
42-
"renderer": {
43-
"webpackConfig": "renderer.webpack.js"
44-
}
45-
},
4640
"build": {
4741
"productName": "ITU OB Editor",
4842
"appId": "org.ituob.editor",
@@ -196,14 +190,10 @@
196190
"jsondiffpatch": "^0.4.1",
197191
"memoize-one": "^5.1.1",
198192
"moment": "^2.24.0",
199-
"react": "^16.11.0",
200-
"react-dnd": "^10.0.2",
201-
"react-dnd-html5-backend": "^10.0.2",
202-
"react-dom": "^16.11.0",
203-
"react-transition-group": "^4.3.0",
204-
"react-window": "^1.8.5",
205-
"source-map-support": "^0.5.19",
206-
"throttle-debounce": "^2.1.0"
193+
"react-dnd": "^16.0.1",
194+
"react-dnd-html5-backend": "^16.0.1",
195+
"react-window": "^1.8.10",
196+
"throttle-debounce": "^5.0.2"
207197
},
208198
"resolutions": {
209199
"*/**/prosemirror-model": "https://github.com/strogonoff/prosemirror-model.git#prosemirror-model-v1.7.5-gitpkg",
@@ -222,6 +212,7 @@
222212
"@types/throttle-debounce": "^2.1.0",
223213
"@typescript-eslint/eslint-plugin": "^4.0.1",
224214
"@typescript-eslint/parser": "^4.0.1",
215+
"@vitejs/plugin-react": "^4.2.0",
225216
"commitizen": "^4.2.1",
226217
"cross-env": "^7.0.0",
227218
"electron": "^9.1.1",
@@ -233,15 +224,18 @@
233224
"eslint": "^7.8.1",
234225
"husky": "^4.2.5",
235226
"native-ext-loader": "^2.3.0",
236-
"node-sass": "^4.12.0",
237227
"npm-run-all": "^4.1.5",
238228
"prettifier": "^0.4.0",
239-
"sass-loader": "^8.0.2",
229+
"react": "^16.11.0",
230+
"react-dom": "^16.11.0",
231+
"sass": "^1.69.0",
240232
"stylelint": "^13.7.0",
241233
"stylelint-config-standard": "^20.0.0",
242234
"threads-plugin": "^1.3.3",
243235
"typescript": "^3.9.7",
244236
"typescript-plugin-css-modules": "^2.2.0",
237+
"vite": "^5.0.0",
238+
"vite-plugin-electron": "^0.28.0",
245239
"webpack": "~4.44.0"
246240
},
247241
"config": {
@@ -254,5 +248,6 @@
254248
"prepare-commit-msg": "exec < /dev/tty && git cz --hook || true",
255249
"pre-push": "yarn lint:ts && yarn lint:css && yarn compile"
256250
}
257-
}
251+
},
252+
"main": "electron.js"
258253
}

renderer.webpack.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/main/index.ts

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
import * as path from 'path';
2-
import { app as electronApp } from 'electron';
1+
import * as path from "path";
2+
import { app as electronApp } from "electron";
33

4-
import { MainConfig } from '@riboseinc/coulomb/config/main';
5-
import { initMain } from '@riboseinc/coulomb/app/main';
4+
import { MainConfig } from "@riboseinc/coulomb/config/main";
5+
import { initMain } from "@riboseinc/coulomb/app/main";
66

7-
import { ManagerOptions } from '@riboseinc/coulomb/db/isogit-yaml/main/manager';
8-
import { default as BackendCls } from '@riboseinc/coulomb/db/isogit-yaml/main/base';
9-
import { default as ModelManagerCls } from '@riboseinc/coulomb/db/isogit-yaml/main/manager';
10-
import { default as FSWrapper } from '@riboseinc/coulomb/db/isogit-yaml/main/yaml/directory';
7+
import { ManagerOptions } from "@riboseinc/coulomb/db/isogit-yaml/main/manager";
8+
import { default as BackendCls } from "@riboseinc/coulomb/db/isogit-yaml/main/base";
9+
import { default as ModelManagerCls } from "@riboseinc/coulomb/db/isogit-yaml/main/manager";
10+
import { default as FSWrapper } from "@riboseinc/coulomb/db/isogit-yaml/main/yaml/directory";
1111

12-
import { default as IssueManagerCls } from './issue-manager';
12+
import { default as IssueManagerCls } from "./issue-manager";
1313

14-
import { conf as appConf } from '../app';
14+
import { conf as appConf } from "../app";
1515

16-
import { OBIssue } from 'models/issues';
17-
import { Publication } from 'models/publications';
18-
import { ITURecommendation } from 'models/recommendations';
19-
20-
21-
const appDataPath = electronApp.getPath('userData');
16+
import { OBIssue } from "models/issues";
17+
import { Publication } from "models/publications";
18+
import { ITURecommendation } from "models/recommendations";
2219

20+
const appDataPath = electronApp.getPath("userData");
2321

2422
export const conf: MainConfig<typeof appConf> = {
2523
app: appConf,
@@ -28,48 +26,54 @@ export const conf: MainConfig<typeof appConf> = {
2826
disableGPU: true,
2927

3028
appDataPath: appDataPath,
31-
settingsFileName: 'ituob-settings',
29+
settingsFileName: "ituob-settings",
3230

3331
databases: {
3432
default: {
3533
backend: BackendCls,
3634
options: {
37-
workDir: path.join(appDataPath, 'ituob-data'),
35+
workDir: path.join(appDataPath, "ituob-data"),
3836
fsWrapperClass: FSWrapper,
3937
},
4038
},
4139
},
4240

4341
managers: {
4442
issues: {
45-
dbName: 'default',
43+
dbName: "default",
4644
options: {
4745
cls: IssueManagerCls,
48-
workDir: 'issues',
49-
idField: 'id',
50-
metaFields: ['id', 'publication_date', 'cutoff_date', 'issn', 'languages', 'authors'],
46+
workDir: "issues",
47+
idField: "id",
48+
metaFields: [
49+
"id",
50+
"publication_date",
51+
"cutoff_date",
52+
"issn",
53+
"languages",
54+
"authors",
55+
],
5156
} as ManagerOptions<OBIssue>,
5257
},
5358
publications: {
54-
dbName: 'default',
59+
dbName: "default",
5560
options: {
5661
cls: ModelManagerCls,
57-
workDir: 'lists',
58-
idField: 'id',
59-
metaFields: ['id', 'url', 'title', 'recommendation'],
62+
workDir: "lists",
63+
idField: "id",
64+
metaFields: ["id", "url", "title", "recommendation"],
6065
} as ManagerOptions<Publication>,
6166
},
6267
recommendations: {
63-
dbName: 'default',
68+
dbName: "default",
6469
options: {
6570
cls: ModelManagerCls,
66-
workDir: 'recommendations',
67-
idField: 'id',
68-
metaFields: ['id', 'version', 'title'],
71+
workDir: "recommendations",
72+
idField: "id",
73+
metaFields: ["id", "version", "title"],
6974
} as ManagerOptions<ITURecommendation>,
7075
},
7176
},
7277
};
7378

74-
7579
export const app = initMain(conf);

0 commit comments

Comments
 (0)