A webpack plugin for generating server-side partial views from webpack assets, enabling SSR frameworks to reference hashed assets without hardcoding. v4.0.0 (current stable) supports Rspack and webpack 5+, with breaking change dropping webpack v2-4 support. v3.x supports webpack v2-5. Key differentiators over other asset plugins: built-in templates for inlining or referencing scripts/styles, rule-based matching by chunk name or regex, and support for custom template functions.
npm install templated-assets-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Minimal webpack config using TemplatedAssetsWebpackPlugin to generate partial views for server-rendered assets.
Upgrade to webpack v5+, or use templated-assets-webpack-plugin@v3 for webpack v2-4.
If you rely on absolute paths (/), set webpack output.publicPath explicitly.
Use require() instead of import statements. For ESM projects, use createRequire or transpile.
Use rules: [...] in the plugin options object.
Use only one of 'name' or 'test' per rule to avoid confusion.
Run 'npm install templated-assets-webpack-plugin --save-dev' or check node_modules path.
Use require('templated-assets-webpack-plugin') instead of import.Ensure each rule's 'name' is a string or array of strings.
Upgrade to templated-assets-webpack-plugin@v3 or v4 for webpack v5 support.