Skip to content

Commit

Permalink
fix: onBundleReady called before manifest is generated in build mode (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alvkn authored Nov 18, 2024
1 parent 1e7b107 commit 69b44c5
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,14 @@ export function manifestLoaderPlugin(options: ResolvedOptions): vite.Plugin {
});
}

if (options.onBundleReady) {
await copyPublicDirToOutDir({ mode, paths });

// Handle the onBundleReady callback in dev mode here, as writeBundle is not called in dev mode
if (mode === BuildMode.DEV && options.onBundleReady) {
logger.verbose("Running onBundleReady");
await options.onBundleReady();
}

await copyPublicDirToOutDir({ mode, paths });

// In dev mode, open up the browser immediately after the build context is finished with the
// first build.
if (mode === BuildMode.DEV && !options.disableAutoLaunch) {
Expand Down Expand Up @@ -287,6 +289,14 @@ export function manifestLoaderPlugin(options: ResolvedOptions): vite.Plugin {
noInput.cleanupBundle(bundle);
},

// Runs during: build, watch
async writeBundle() {
if (options.onBundleReady) {
logger.verbose("Running onBundleReady");
await options.onBundleReady();
}
},

// Runs during: watch, dev
async watchChange(id) {
if (
Expand Down

0 comments on commit 69b44c5

Please sign in to comment.