Document how to use Vite with preload scripts
- Dominant language
- TypeScript
- Stars
- 7.1k
- Forks
- 641
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 30
Description
### Pre-flight checklist
- [X] I have read the [contribution documentation](https://github.com/electron/forge/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project uses.
- [X] I have searched the issue tracker for a feature request that matches the one I want to file, without success.
### Problem description
The current [Vite Plugin documentation](https://www.electronforge.io/config/plugins/vite) shows how to include a preload script into a Vite build, but it does not explain how the magic globals get named or how to address them in a `new BrowserWindow()` call.
I'm looking into moving from Webpack, so I'm thinking about this from Webpack point of view, but the example doesn't make it clear how to address scripts from the `config.build` array.
### Proposed solution
Expand to the `main.js` example code to show a proper `new BrowserWindow()` call.
Something like:
```JS
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: PATH_USING_MAGIC_GLOBAL
}
});
```
### Alternatives considered
n/a
### Additional information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.