插件视频
这个插件可以方便地设置标准 vite 工具来编译您的主要进程代码和您的渲染器进程代码,在渲染器过程中内置支持Hot模块替换(HMR),支持多个渲染器.
// forge.config.js
module.exports = {
plugins: [
{
name: '@electron-forge/plugin-vite',
config: {
// `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
// If you are familiar with Vite configuration, it will look really familiar.
build: [
{
// `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
entry: 'src/main.js',
config: 'vite.main.config.mjs'
},
{
entry: 'src/preload.js',
config: 'vite.preload.config.mjs'
}
],
renderer: [
{
name: 'main_window',
config: 'vite.renderer.config.mjs'
}
]
}
}
]
};
主进程热启动
渲染器代码由Vite从盒子中取出热重装,但主要流程代码是
而非:应用程序必须重新启动才能取回. 设定 hotRestart 拥有
electron-forge start 每当一个主进程捆绑重建时,就这样做:
// forge.config.js
module.exports = {
plugins: [
{
name: '@electron-forge/plugin-vite',
config: {
hotRestart: true,
build: [
{
entry: 'src/main.js',
config: 'vite.main.config.mjs'
}
],
renderer: []
}
}
]
};
这是默认关闭的,所以主进程更改 否则只有当
键 rs 在终端中或重新启动 electron-forge start选项
包装时没有效果.