You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-17Lines changed: 16 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,13 +12,11 @@
12
12
13
13
## Overview
14
14
15
-
This is an `Electron` category integration template that pursues simplification.
16
-
This contains only the most basic files, the most basic dependencies, and the most basic functions. Instead of large and complex design.
17
-
The purpose of this is to ensure that the template is flexible enough.
15
+
This is an `Vite`-integrated `Electron` template built with simplification in mind.
18
16
19
-
For all that, I still hope that you have a basic understanding for `Electron``Vite`. Because in addition to the simple structure of the project, the `README` also appears too simplify.
17
+
The repo contains only the most basic files, dependencies and functionalities to ensure flexibility for various scenarios.
20
18
21
-
You can learn more details by looking at the source code. Trust me, this template is the simple enough. 😋
19
+
You need a basic understanding of `Electron` and `Vite` to get started. But that's not mandatory - you can learn almost all the details by reading through the souce code. Trust me, this repo is not that complex. 😋
22
20
23
21
## Run Setup
24
22
@@ -38,17 +36,17 @@ You can learn more details by looking at the source code. Trust me, this templat
38
36
39
37
## Directory
40
38
41
-
Once `dev` or `build` npm-script executed will be generate named `dist` folder. It has children dir of same as `packages` folder, the purpose of this design can ensure the correct path calculation.
39
+
A `dist` folder will be generated everytime when `dev` or `build` command is executed. File structure of `dist` is identical to the `packages` directory to avoid any potential path calculation errors.
42
40
43
41
```tree
44
42
├
45
-
├── dist After build, it's generated according to the "packages" directory
43
+
├── dist Will be generated following the structure of "packages" directory
46
44
├ ├── main
47
45
├ ├── preload
48
46
├ ├── renderer
49
47
├
50
48
├── scripts
51
-
├ ├── build.mjs Develop script -> npm run build
49
+
├ ├── build.mjs Build script -> npm run build
52
50
├ ├── watch.mjs Develop script -> npm run dev
53
51
├
54
52
├── packages
@@ -63,9 +61,11 @@ Once `dev` or `build` npm-script executed will be generate named `dist` folder.
63
61
64
62
## Use Electron, NodeJs API
65
63
66
-
> 🚧 By default, Electron don't support the use of API related to Electron and NodeJs in the Renderer-process, but someone still need to use it. If so, you can see the template 👉 **[electron-vite-boilerplate](https://github.com/caoxiemeihao/electron-vite-boilerplate)**
64
+
> 🚧 By default, using Electron or NodeJS API in the rederer process is discouraged. For anyone who needs to bypass this security constrain, take a look at this template 👉 **[electron-vite-boilerplate](https://github.com/caoxiemeihao/electron-vite-boilerplate)**
67
65
68
-
#### All Electron, NodeJs API invoke passed `Preload-script`
66
+
As electron suggested, if you need access to the Electron and NodeJS API in the renderer process, you need to create a context bridge and expose the APIs you need to the renderer process.
67
+
68
+
Note that if your project uses typescript, you also need to add type declearations to `Window` interface.
69
69
70
70
***packages/preload/index.ts**
71
71
@@ -98,12 +98,11 @@ Once `dev` or `build` npm-script executed will be generate named `dist` folder.
98
98
99
99
## Use SerialPort, SQLite3 or other node-native addons in Main-process
100
100
101
-
- First, yout need to make sure the deps in "dependencies". Because the project still needs it after packaged.
101
+
- First you need to make sure the packages are listed in the "dependencies", since they are still needed during runtime after the project is bundled.
102
102
103
-
- Main-process, Preload-script are also built with Vite, and they are just built as [build.lib](https://vitejs.dev/config/#build-lib).
104
-
So they just need to configure Rollup.
103
+
- Source code of main process and preload scripts are also bundled with Vite[build.lib](https://vitejs.dev/config/#build-lib). Rollup configurations are needed.
105
104
106
-
**Click to see more** 👉 [packages/main/vite.config.ts](https://github.com/caoxiemeihao/electron-vue-vite/blob/main/packages/main/vite.config.ts)
- First, you need to know if deps(npm package) are still needed after packaged.
129
+
- First, you need to know if the package is still needed during runtime after packaged.
131
130
132
-
-Like [serialport](https://www.npmjs.com/package/serialport), [sqlite3](https://www.npmjs.com/package/sqlite3)they are node-native module and should be placed in `dependencies`. In addition, Vite will not build them, but treat them as external modules.
131
+
-Packages like [serialport](https://www.npmjs.com/package/serialport), [sqlite3](https://www.npmjs.com/package/sqlite3) are node-native modules and should be placed in `dependencies`. Vite will not build them and will treat them as externals.
133
132
134
-
-Like [vue](https://www.npmjs.com/package/vue), [react](https://www.npmjs.com/package/react)they are pure javascript module and can be built with Vite, so they can be placed in `devDependencies`. This reduces the volume of the built project.
133
+
-Packages like [vue](https://www.npmjs.com/package/vue), [react](https://www.npmjs.com/package/react) are pure javascript modules and can be built with Vite. They can be listed in `devDependencies` which helps reducing the size of bundled product.
0 commit comments