Home > @lynx-js/template-webpack-plugin > TemplateHooks
#TemplateHooks interface
To allow other plugins to alter the Template, this plugin executes tapable hooks.
Signature:
export interface TemplateHooks #Example
class MyPlugin {
apply(compiler) {
compiler.hooks.compilation.tap("MyPlugin", (compilation) => {
console.log("The compiler is starting a new compilation...");
LynxTemplatePlugin.getLynxTemplatePluginHooks(compilation).beforeEmit.tapAsync(
"MyPlugin", // <-- Set a meaningful name here for stacktraces
(data, cb) => {
// Manipulate the content
modifyTemplate(data.template)
// Tell webpack to move on
cb(null, data);
},
);
});
}
}#Properties
|
Property |
Modifiers |
Type |
Description |
|---|---|---|---|
|
AsyncSeriesWaterfallHook<{ outputName: string; }> |
(ALPHA) Called after the template is emitted. | ||
|
SyncWaterfallHook<string> |
(ALPHA) Get the real name of an async chunk. The files with the same | ||
|
AsyncSeriesWaterfallHook<{ finalEncodeOptions: EncodeOptions; debugInfo: string; template: Buffer; outputName: string; mainThreadAssets: Asset[]; cssChunks: Asset[]; entryNames: string[]; }> |
(ALPHA) Called before the template is emitted. Can be used to modify the template. | ||
|
AsyncSeriesWaterfallHook<{ encodeData: EncodeRawData; filenameTemplate: string; entryNames: string[]; intermediate: string; intermediateAssets: string[]; }> |
(ALPHA) Called before the encode process. Can be used to modify the encode options. | ||
|
AsyncSeriesBailHook<{ encodeOptions: EncodeOptions; intermediate?: string; }, { buffer: Buffer; debugInfo: string; }> |
(ALPHA) Call the encode process. |

