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 contententry: CompileEntrythe information about the entry containing all dependent assets,
the description of theTemplateInfosee by postprocesscompilation: Compilation- the Webpack compilation object
Return new content as a string.
If return undefined then content will not be changed.