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
+3-109Lines changed: 3 additions & 109 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@ This repository contains the starter template for using vue-next with the latest
4
4
5
5
*I started to learn electron & vue by the great project [electron-vue](https://github.com/SimulatedGREG/electron-vue). This project is also inspired from it.*
6
6
7
+
You can see the document [here](https://ci010.github.io/electron-vue-next/index.html).
8
+
7
9
## Features
8
10
9
11
- Electron 10
@@ -39,14 +41,10 @@ This repository contains the starter template for using vue-next with the latest
39
41
Clone or fork this project to start.
40
42
Once you have your project, and in the project folder:
41
43
42
-
```sh
44
+
```shell
43
45
# Install dependencies with linter
44
46
npm install
45
47
46
-
# OR install dependencies without eslint
47
-
npm install --no-optional
48
-
```
49
-
```sh
50
48
# Will start vite server, rollup devserver, and electron to dev!
51
49
npm run dev
52
50
@@ -60,107 +58,3 @@ npm run build:dir
60
58
npm run build:production
61
59
62
60
```
63
-
64
-
### Using NodeJS in Renderer
65
-
66
-
Due to the project is following the [security](https://www.electronjs.org/docs/tutorial/security) guideline. It does not allow the renderer to access node by default. You should use [Service](/src/main/services/Service.ts) to encapsulate your nodejs operation and use the hook `useService('NameOfService')` to use in renderer side.
67
-
68
-
### Config Your Project and Build
69
-
70
-
Once you install your project, you should change the package base info in [package.json](/package.json),
71
-
and also the build information in [/scripts/build.base.config.js](/scripts/build.base.config.js)
72
-
73
-
#### assets, static resources, build resources... what's the difference?
74
-
75
-
The assets is only used by the renderer process (in-browser display), like picture or font. They are **bundled by vite/rollup**. You can directly `import` them in `.vue/.ts` files under renderer directory. The default assets are in [/src/renderer/assets](src/renderer/assets)
76
-
77
-
The static resources are the static files which main process wants to access (like read file content) in **runtime vie file system**. They might be the tray icon file, browser window icon file. The static folder is at [/static](static).
78
-
79
-
The build resources are used by `electron-builder` to build the installer. They can be your program icon of installer, or installer script. Default build icons are under [/build/icons](build/icons).
80
-
81
-
*Notice that your program icon can show up in multiple place! Don't mixup them!*
82
-
-*In build icons, of course you want your program has correct icon.*
83
-
-*In static directory, sometime you want your program has **tray** which require icon in static directory.*
84
-
-*In assets, sometime you want to display your program icon inside a page. You need to place them in the assets!*
85
-
86
-
### Debug In VSCode
87
-
88
-
This is really simple. In vscode debug section, you will see three profiles:
89
-
90
-
1. Electron: Main (attach)
91
-
2. Electron: Renderer (attach)
92
-
3. Electron: Main & Renderer (attach)
93
-
94
-
The name should be clear. The first one attach to main and the second one attach to renderer (required vscode chrome debug extension).
95
-
The third one is run the 1 and 2 at the same time.
96
-
97
-
You should first run `npm run dev` and start debugging by the vscode debug.
98
-
99
-
### Adding New Dependencies
100
-
101
-
If you adding new dependenceis, make sure if it using nodejs module, add it as `exclude` in the [/scripts/vite.config.js](/scripts/vite.config.js). Otherwise, the vite will complain about "I cannot optimize it!".
102
-
103
-
The raw javascript dependencies are okay for vite.
104
-
105
-
#### Native Dependencies
106
-
107
-
If you want to use the native dependencies, not only you should adding it to vite `exclude`, you should also take care about the electron-builder config.
108
-
109
-
For example, [7zip-min](https://github.com/onikienko/7zip-min):
110
-
111
-
Since it using the `7zip-bin` which carry binary for multiple platform, we need to correctly include them in config.
112
-
Modify the electron-builder build script [/scripts/build.base.config.js](/scripts/build.base.config.js)
113
-
114
-
```js
115
-
files: [
116
-
"dist/electron/**/*",
117
-
"!**/node_modules/**/*",
118
-
"node_modules/7zip-bin/**/*"
119
-
],
120
-
asarUnpack: [
121
-
"node_modules/7zip-bin/**/*"
122
-
],
123
-
```
124
-
125
-
Add them to `files` and `asarUnpack` to ensure the electron builder correctly pack & unpack them.
126
-
127
-
To optimize for multi-platform, you should also exclude them from `files` of each platform config [/scripts/build.config.js](/scripts/build.config.js)
128
-
129
-
```js
130
-
mac: {
131
-
// ... other mac configs
132
-
files: [
133
-
"node_modules/7zip-bin/**/*",
134
-
"!node_modules/7zip-bin/linux/**",
135
-
"!node_modules/7zip-bin/win/**"
136
-
]
137
-
},
138
-
win: {
139
-
// ... other win configs
140
-
files: [
141
-
"node_modules/7zip-bin/**/*",
142
-
"!node_modules/7zip-bin/linux/**",
143
-
"!node_modules/7zip-bin/mac/**"
144
-
]
145
-
},
146
-
linux: {
147
-
// ... other linux configs
148
-
files: [
149
-
"node_modules/7zip-bin/**/*",
150
-
"!node_modules/7zip-bin/win/**",
151
-
"!node_modules/7zip-bin/mac/**"
152
-
]
153
-
},
154
-
```
155
-
156
-
### Release Process
157
-
158
-
The out-of-box github action will validate each your PR by eslint and run `npm run build`. It will not trigger electron-builder to build production assets.
159
-
160
-
For each push in master branch, it will build production assets for win/mac/linux platform and upload it as github action assets. It will also create a **pull request** to asking you to bump version and update the changelog.
161
-
162
-
It using the conventional-commit. If you want to auto-generate the changelog, you should follow the [conventional commit guideline](https://www.conventionalcommits.org/en/v1.0.0).
163
-
164
-
If the **bump version PR** is approved and merged to master, it will auto build and release to github release.
165
-
166
-
**If you want to disable this github action release process, just remove the [/.github/workflows/build.yml](/.github/workflows/build.yml) file.**
0 commit comments