Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin-vite): stop the world #3736

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(plugin-vite): stop the world
smallsung committed Oct 10, 2024
commit 4332474ed600b47bed235cd53d2b1ce961ba9bc4
2 changes: 1 addition & 1 deletion packages/plugin/vite/src/VitePlugin.ts
Original file line number Diff line number Diff line change
@@ -164,7 +164,7 @@ the generated files). Instead, it is ${JSON.stringify(pj.main)}`);
// Avoid recursive builds caused by users configuring @electron-forge/plugin-vite in Vite config file.
configFile: false,
...userConfig,
plugins: [onBuildDone(resolve), ...(userConfig.plugins ?? [])],
plugins: [onBuildDone(resolve, reject), ...(userConfig.plugins ?? [])],
})
.then((result) => {
if (isWatcher(result)) {
15 changes: 12 additions & 3 deletions packages/plugin/vite/src/util/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import type { Plugin } from 'vite';

export function onBuildDone(callback: () => void) {
export function onBuildDone(onfulfilled: () => void, onrejected: (error: Error) => void) {
return {
name: '@electron-forge/plugin-vite:build-done',
closeBundle() {
callback();
buildEnd(error) {
error && onrejected(error);
},
generateBundle(options, bundle, isWrite) {
isWrite || onfulfilled();
},
writeBundle() {
onfulfilled();
},
renderError(error) {
error && onrejected(error);
},
} as Plugin;
}