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: docs/guide/commonIssues.md
+1-17Lines changed: 1 addition & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,34 +32,18 @@ if (isDevelopment && !process.env.IS_TEST) {
32
32
}
33
33
```
34
34
35
-
## Strict mime-type error when running a built app
36
-
37
-
:::tip Notice
38
-
As of v1.0.0-rc.5, this tag is no longer necessary. You can remove it if you wish.
39
-
:::
40
-
41
-
This is likely caused because you are missing code in your `public/index.html` file. To add it, simply run `vue invoke electron-builder`. This will re-invoke the generator of VCP Electron Builder. Any missing code will be detected and added automatically. If you would not like to re-invoke the generator, you can paste this code into the top of the `<head>` of your `public/index.html`:
42
-
43
-
```html
44
-
<% if (BASE_URL === './') { %><basehref="app://./" /><% } %>
45
-
```
46
-
47
35
## Exceptions in `async` functions not getting logged to console
48
36
49
37
This bug can be fixed by adding the following code to the entrypoint of your Vue App `src/main.js`:
50
38
51
39
```javascript
52
-
process.on('unhandledRejection', error=> {
40
+
process.on('unhandledRejection', (error)=> {
53
41
console.error(error)
54
42
})
55
43
```
56
44
57
45
See [#118](https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/118) for more details. Thanks to [dspangenberg](https://github.com/dspangenberg) for the fix.
58
46
59
-
## Electron not opening on Node v11
60
-
61
-
Make sure you are using Electron v2.0.14+ or v3.0.10+. Also, make sure Node is v11.2.0+. See [#107 (comment)](https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/107#issuecomment-441168465) for more details.
62
-
63
47
## Other issues
64
48
65
49
Many issues can be solved by re-invoking the generator of Vue CLI Plugin Electron Builder. This allows it to add newer code to your project files. You may need to do this after upgrading the plugin.
Copy file name to clipboardExpand all lines: docs/guide/configuration.md
+11-25Lines changed: 11 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,13 +47,13 @@ module.exports = {
47
47
},
48
48
pluginOptions: {
49
49
electronBuilder: {
50
-
chainWebpackMainProcess:config=> {
50
+
chainWebpackMainProcess:(config)=> {
51
51
// Chain webpack config for electron main process only
52
52
},
53
-
chainWebpackRendererProcess:config=> {
53
+
chainWebpackRendererProcess:(config)=> {
54
54
// Chain webpack config for electron renderer process only
55
55
// The following example will set IS_ELECTRON to true in your app
56
-
config.plugin('define').tap(args=> {
56
+
config.plugin('define').tap((args)=> {
57
57
args[0]['IS_ELECTRON'] =true
58
58
return args
59
59
})
@@ -63,7 +63,7 @@ module.exports = {
63
63
// Provide an array of files that, when changed, will recompile the main process and restart Electron
64
64
// Your main process file will be added by default
65
65
mainProcessWatch: ['src/myFile1', 'src/myFile2'],
66
-
//[1.0.0-rc.4+] Provide a list of arguments that Electron will be launched with during "electron:serve",
66
+
// Provide a list of arguments that Electron will be launched with during "electron:serve",
67
67
// which can be accessed from the main process (src/background.js).
68
68
// Note that it is ignored when --debug flag is used with "electron:serve", as you must launch Electron yourself
69
69
// Command line args (excluding --debug, --dashboard, and --headless) are passed to Electron as well
@@ -73,25 +73,11 @@ module.exports = {
73
73
}
74
74
```
75
75
76
-
## Node Integration
77
-
78
-
As of v2.0, electron `nodeIntegration` is disabled by default. This blocks all node APIs such as `require`. This reduces [security risks](https://electronjs.org/docs/tutorial/security#2-do-not-enable-nodejs-integration-for-remote-content), and is a recommended best practice by the electron team. If you need to use native modules such as `fs` or `sqlite` in the renderer process, you can enable `nodeIntegration` in `vue.config.js`:
79
-
80
-
```js
81
-
module.exports= {
82
-
pluginOptions: {
83
-
electronBuilder: {
84
-
nodeIntegration:true
85
-
}
86
-
}
87
-
}
88
-
```
89
-
90
76
## Changing the Output Directory
91
77
92
-
If you don't want your files outputted into dist_electron, you can choose a custom folder in vue-cli-plugin-electron-builder's plugin options. If you are using `v1.0.0-rc.4` or later, you can use the `--dest` argument to change the output dir as well.
78
+
If you don't want your files outputted into dist_electron, you can choose a custom folder in VCPEB's plugin options. You can use the `--dest` argument to change the output dir as well.
93
79
94
-
**Note: If you are using version 1.0.0-rc.3 or lower, after changing this, you MUST update the main field of your `package.json` to `[new dir]/bundled/background.js`. It is also recommended to add the new directory to your .gitignore file.**
80
+
**Note: It is recommended to add the new directory to your .gitignore file.**
95
81
96
82
```javascript
97
83
// vue.config.js
@@ -123,11 +109,11 @@ module.exports = {
123
109
}
124
110
```
125
111
126
-
:::tip Tip <Badgetext="1.0.0-rc.1+"type="info"/>
112
+
:::tip Tip
127
113
If you decide to add the `@vue/typescript` plugin to your app later on, make sure to re-invoke the generator of VCP-Electron-Builder with `vue invoke electron-builder`. This will automatically insert missing type definitions to your `background.ts` file.
128
114
:::
129
115
130
-
## Changing the File Loading Protocol <Badgetext="1.0.0+"type="info"/>
116
+
## Changing the File Loading Protocol
131
117
132
118
By default, the `app` protocol is used to load files. This allows you to use ES6 `type="module"` scripts, created by Vue CLI's [modern mode](https://cli.vuejs.org/guide/browser-compatibility.html#modern-mode). If, for some reason, you would like to use a different protocol, set it with the `customFileProtocol` option, and change it in your `background.js` file.
133
119
@@ -150,11 +136,11 @@ win.loadURL('myCustomProtocol://./index.html') // Change it here as well
By default, the app is built in [modern mode](https://cli.vuejs.org/guide/browser-compatibility.html#modern-mode). To disable this, use the `--legacy` argument in the `electron:build` command. If your app is already bundled and just needs to be built with electron-builder, pass the `--skipBundle` arg.
Copy file name to clipboardExpand all lines: docs/guide/guide.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,7 +125,7 @@ win = new BrowserWindow({
125
125
126
126
## Env Variables
127
127
128
-
Read [Vue ClI's documentation](https://cli.vuejs.org/guide/mode-and-env.html) to learn about using environment variables in your app. All env variables prefixed with `VUE_APP_` will be available in both the main and renderer processes (Only available in main process since `1.0.0-rc.4`).
128
+
Read [Vue ClI's documentation](https://cli.vuejs.org/guide/mode-and-env.html) to learn about using environment variables in your app. All env variables prefixed with `VUE_APP_` will be available in both the main and renderer processes.
As of v2.0 of VCPEB, Electron `nodeIntegration` is disabled by default. This blocks all node APIs such as `require`. This reduces [security risks](https://electronjs.org/docs/tutorial/security#2-do-not-enable-nodejs-integration-for-remote-content), and is a recommended best practice by the Electron team. If you need to use native modules such as `fs` or `sqlite` in the renderer process, you can enable `nodeIntegration` in `vue.config.js`:
8
+
9
+
```js
10
+
module.exports= {
11
+
pluginOptions: {
12
+
electronBuilder: {
13
+
nodeIntegration:true
14
+
}
15
+
}
16
+
}
17
+
```
18
+
19
+
:::tip IPC With Node Integration
20
+
You can still use [IPC](https://www.electronjs.org/docs/api/ipc-renderer) with `nodeIntegration`. Just create a [preload script](./guide.html#preload-files) with the following code:
21
+
22
+
```js
23
+
import { ipcRenderer } from'electron'
24
+
window.ipcRenderer= ipcRenderer
25
+
```
26
+
27
+
Now, you can access `ipcRenderer` with `window.ipcRenderer` in your Vue app.
28
+
:::
29
+
30
+
## Loading Local Images/Resources
31
+
32
+
If WebSecurity is enabled, you won't be able to load resources from the file system, ie `<img src="file://image.png"/>`. [Disabling WebSecurity is strongly discouraged](https://www.electronjs.org/docs/tutorial/security#5-do-not-disable-websecurity), so you should instead use the following technique to load local resources and keep WebSecurity enabled.
33
+
34
+
Add the following to your main process file (`background.(js|ts)` by default):
0 commit comments