Skip to content

Commit 9231668

Browse files
authored
Add to plugins/vite.md information about custom path for renderer
1 parent c23f806 commit 9231668

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

config/plugins/vite.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,51 @@ module.exports = {
141141
```
142142
{% endcode %}
143143

144+
### Custom root for renderer
145+
146+
Under the hood, the Vite plugin merge user based config with own config.
147+
{% code title="packages/plugin/vite/src/config/vite.renderer.config.ts" %}
148+
```typescript
149+
const config: UserConfig = {
150+
root,
151+
mode,
152+
base: './',
153+
build: {
154+
copyPublicDir: true,
155+
outDir: `.vite/renderer/${name}`,
156+
},
157+
plugins: [pluginExposeRenderer(name)],
158+
resolve: {
159+
preserveSymlinks: true,
160+
},
161+
clearScreen: false,
162+
};
163+
```
164+
{% endcode %}
165+
166+
Here, root is the absolute path to the root directory.
167+
168+
If root is overridden in the user configuration, the resulting path before the build is incorrect, and the renderer files are not moved to the `out` directory.
169+
170+
To avoid this behavior, you also need to update the relative path in the `build.outDir` field. See the example for more details.
171+
172+
{% code title="vite.renderer.config.ts" %}
173+
```typescript
174+
import path from 'node:path';
175+
import { defineConfig } from 'vite';
176+
177+
export default defineConfig({
178+
base: './',
179+
root: path.join(__dirname, 'src', 'renderer', 'MainWindow'),
180+
build: {
181+
copyPublicDir: true,
182+
outDir: path.join('..', '..', '..', '.vite', 'renderer', 'main_window'),
183+
},
184+
});
185+
186+
```
187+
{% endcode %}
188+
144189
### Native Node modules
145190

146191
If you used the [Vite](../../templates/vite.md) template to create your application, native modules will mostly work out of the box. However, to avoid possible build issues, we recommend instructing Vite to load them as external packages:

0 commit comments

Comments
 (0)