Skip to main content

Callback beforeEmit

Option: beforeEmit

Type:

type BeforeEmit = (
content: string,
entry: CompileEntry,
compilation: Compilation
) => string | undefined;

type CompileEntry = TemplateInfo & {
// assets used in html
assets: Array<CompileAsset>;
};

Default: null

Called at the latest stage of the processAssets hook, before emitting. This is the latest stage where you can change the HTML before it will be saved on the disk.

Callback parameters:

  • content: string - the final version html content
  • entry: CompileEntry the information about the entry containing all dependent assets,
    the description of the TemplateInfo see by postprocess
  • compilation: Compilation - the Webpack compilation object

Return new content as a string. If return undefined then content will not be changed.