Skip to content

Commit

Permalink
perf: no need to polyfill module preload for the Electron renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
alex8088 committed Mar 28, 2022
1 parent ef99b02 commit 82477b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ function createWindow() {
| ├──preload
| | ├──index.js
| | └──...
| ──renderer
| | ├──src
| | ├──index.html
| | └──...
| ──renderer
| ├──src
| ├──index.html
| └──...
├──electron.vite.config.js
└──package.json
```
Expand Down Expand Up @@ -178,6 +178,7 @@ See [vitejs.dev](https://vitejs.dev/config)
- **outDir**: `out\renderer`(relative to project root)
- **target**: `chrome*`, automatically match chrome target of `Electron`. For example, the chrome target of Electron 17 is `chrome98`
- **lib.entry**: `src\renderer\index.html`(relative to project root), empty string if not found
- **polyfillModulePreload**: `false`, there is no need to polyfill `Module Preload` for the Electron renderer
- **rollupOptions.external**: the same as `main`

#### Define option for `main` and `preload`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "electron-vite",
"version": "1.0.0",
"version": "1.0.1",
"description": "Use vite for your electron app.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export function electronRendererVitePlugin(options?: ElectronPluginOptions): Plu
build: {
outDir: path.resolve(root, 'out', 'renderer'),
target: chromeTarget,
polyfillModulePreload: false,
rollupOptions: {
input: findInput(root),
external: [...builtinModules.flatMap(m => [m, `node:${m}`])]
Expand Down

0 comments on commit 82477b6

Please sign in to comment.