Skip to content

Commit 2c30da5

Browse files
authored
Merge pull request #58 from electron-vite/dev
Dev
2 parents 9b8e3f3 + 28cc36c commit 2c30da5

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

.vitepress/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export default defineConfig({
7171
items: [
7272
{ text: 'Electron Forge', link: '/faq/electron-forge' },
7373
{ text: 'dependencies vs devDependencies', link: '/faq/dependencies' },
74+
{ text: 'Debug', link: '/faq/debug' },
7475
],
7576
},
7677
],

faq/debug.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Debug
2+
3+
::: tip Note
4+
If the IDE you are using is VSCode, you can directly use the existing [template](/guide/templates) project.
5+
:::
6+
7+
## Pass args
8+
9+
```ts
10+
// vite.config.ts
11+
import electron from 'vite-plugin-electron'
12+
13+
export default {
14+
plugins: [
15+
electron({
16+
entry: 'electron/main/index.ts',
17+
onstart({ startup }) {
18+
startup([
19+
'.',
20+
'--no-sandbox',
21+
'--sourcemap',
22+
// For Chrome devtools
23+
'--remote-debugging-port=9222',
24+
])
25+
},
26+
}),
27+
],
28+
}
29+
```

guide/dependency-pre-bundling.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,43 @@ export default {
5656
],
5757
}
5858
```
59+
60+
## Advance
61+
62+
So far, Pre-Bundling of [vite-plugin-electron-renderer](https://github.com/electron-vite/vite-plugin-electron-renderer) is still considered an "experimental" feature.
63+
64+
Below is an example showing how to fully customize a Pre-Bundling.
65+
66+
<details>
67+
<summary>中文</summary>
68+
<p>目前为止,<a target="_blank" href="https://github.com/electron-vite/vite-plugin-electron-renderer">vite-plugin-electron-renderer</a> 的 Pre-Bundling 仍然被视为是一个“实验性”的功能。</p>
69+
<p>下面是展示如何完全自定义预构建的案例。</p>
70+
</details>
71+
72+
```ts
73+
// vite.config.ts
74+
import { defineConfig } from 'vite'
75+
import renderer from 'vite-plugin-electron-renderer'
76+
77+
// https://vitejs.dev/config/
78+
export default defineConfig({
79+
plugins: [
80+
// Use Node.js API in the Renderer process
81+
renderer({
82+
resolve: {
83+
'node-fetch': {
84+
type: 'esm',
85+
async build(args) {
86+
// 1. Simple code snippet
87+
return `export * from 'node-fetch'`
88+
89+
// 2. Build using built-in shortcuts
90+
return args.cjs(`export default require('node-fetch');`)
91+
return args.esm('node-fetch', { /* esbuild options */ })
92+
},
93+
},
94+
},
95+
}),
96+
],
97+
})
98+
```

0 commit comments

Comments
 (0)