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
Static assets work similarily to a regular app. Read Vue CLI's documentation [here](https://cli.vuejs.org/guide/html-and-static-assets.html). However, there are a few changes made:
103
+
#### Renderer process (main app):
104
+
In the renderer process, static assets work similarly to a regular app. Read Vue CLI's documentation [here](https://cli.vuejs.org/guide/html-and-static-assets.html) before continuing. However, there are a few changes made:
103
105
104
106
- The `__static` global variable is added. It provides a path to your public directory in both development and production. Use this to read/write files in your app's public directory.
105
107
- In production, the `process.env.BASE_URL` is replaced with the path to your app's files.
106
108
107
109
**Note: `__static` is not available in regular build/serve. It should only be used in electron to read/write files on disk. To import a file (img, script, etc...) and not have it be transpiled by webpack, use the `process.env.BASE_URL` instead.**
110
+
#### Main process (background.js):
111
+
The main process won't have access to `process.env.BASE_URL` or `src/assets`. However, you can still use `__static` to get a path to your public directory in development and production.
108
112
#### Examples:
109
113
```html
114
+
<!-- Renderer process only -->
110
115
<!-- This image will be processed by webpack and placed under img/ -->
111
116
<imgsrc="./assets/logo.png">
117
+
<!-- Renderer process only -->
112
118
<!-- This image will no be processed by webpack, just copied-->
113
119
<!-- imgPath should equal `path.join(process.env.BASE_URL, 'logo.png')` -->
114
120
<img:src="imgPath">
121
+
<!-- Both renderer and main process -->
115
122
<!-- This will read the contents of public/myText.txt -->
0 commit comments