For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/packages/react-rsbuild-plugin/interfaces/TemplateHooks.md.
Lynx
  • English
  • Interface: TemplateHooks

    To allow other plugins to alter the Template, this plugin executes tapable hooks.

    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

    afterEmit

    afterEmit: AsyncSeriesWaterfallHook<{ outputName: string; }>

    Alpha

    Called after the template is emitted.


    asyncChunkName

    asyncChunkName: SyncWaterfallHook<string>

    Alpha

    Get the real name of an async chunk. The files with the same asyncChunkName will be placed in the same template.


    beforeEmit

    beforeEmit: AsyncSeriesWaterfallHook<{ chunkGroups: ChunkGroup[]; cssChunks: Asset[]; cssDiagnostics?: string; debugInfo: string; finalEncodeOptions: EncodeOptions; mainThreadAssets: Asset[]; outputName: string; template: Buffer; }>

    Alpha

    Called before the template is emitted. Can be used to modify the template.


    beforeEncode

    beforeEncode: AsyncSeriesWaterfallHook<{ chunkGroups: ChunkGroup[]; encodeData: EncodeRawData; filenameTemplate: string; intermediate: string; intermediateAssets: string[]; }>

    Alpha

    Called before the encode process. Can be used to modify the encode options.


    encode

    encode: AsyncSeriesBailHook<{ encodeOptions: EncodeOptions; intermediate?: string; }, { buffer: Buffer; cssDiagnostics?: string; debugInfo: string; }>

    Alpha

    Call the encode process.

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.