diff --git a/README.md b/README.md index d3c1a54b..7c0f0211 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Currently supports: | Hook | Rollup | Vite | Webpack 4 | Webpack 5 | | ---- | :----: | :--: | :-------: | :-------: | | [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | +| [`buildEnd`](https://rollupjs.org/guide/en/#buildend) | ✅ | ✅ | ✅ | ✅ | | `transformInclude`* | ✅ | ✅ | ✅ | ✅ | | [`transform`](https://rollupjs.org/guide/en/#transformers) | ✅ | ✅ | ✅ | ✅ | | [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌\*\* | ✅ | ✅ | ✅ | diff --git a/src/types.ts b/src/types.ts index d0af35d4..ca12a889 100644 --- a/src/types.ts +++ b/src/types.ts @@ -19,6 +19,7 @@ export interface UnpluginOptions { name: string; enforce?: 'post' | 'pre' | undefined; buildStart?: () => Promise | void; + buildEnd?: () => Promise | void; transformInclude?: (id: string) => boolean; transform?: (this: UnpluginContext, code: string, id: string) => Thenable; load?: (this: UnpluginContext, id: string) => Thenable diff --git a/src/webpack/index.ts b/src/webpack/index.ts index 29aa2e3f..37a69b71 100644 --- a/src/webpack/index.ts +++ b/src/webpack/index.ts @@ -158,6 +158,12 @@ export function getWebpackPlugin ( } plugin.buildStart?.() + + if (plugin.buildEnd) { + compiler.hooks.done.tapAsync(plugin.name, () => { + plugin.buildEnd!() + }) + } } } }