Registry / web-framework / templated-assets-webpack-plugin

templated-assets-webpack-plugin

JSON →
library4.0.0jsnpmunverified

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-plugin
INSTALL
IMPORT
SIG · TEMPLATED-ASSETS-W
T
templated-assets-webpack-plugin
web-frameworkjavascriptv4.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TemplatedAssetsWebpackPlugin
✓ const TemplatedAssetsWebpackPlugin = require('templated-assets-webpack-plugin');
✗ import TemplatedAssetsWebpackPlugin from 'templated-assets-webpack-plugin';
CJS only; package does not expose ESM. Use require() for all versions.
default
✓ const TemplatedAssetsWebpackPlugin = require('templated-assets-webpack-plugin');
✗ const { TemplatedAssetsWebpackPlugin } = require('templated-assets-webpack-plugin');
Default export is the constructor. Named destructuring is incorrect.
rules
✓ new TemplatedAssetsWebpackPlugin({ rules: [...] })
✗ new TemplatedAssetsWebpackPlugin({ rule: [...] })
Configuration key is 'rules', not 'rule'. Singular spelling is a common mistake.

Minimal webpack config using TemplatedAssetsWebpackPlugin to generate partial views for server-rendered assets.

const path = require('path'); const TemplatedAssetsWebpackPlugin = require('templated-assets-webpack-plugin'); module.exports = { entry: { app: './index.js' }, output: { filename: '[name].[contenthash].js', publicPath: '' }, plugins: [ new TemplatedAssetsWebpackPlugin({ rules: [ { name: ['app', 'vendors'] }, { name: 'runtime', output: { inline: true } } ] }) ], optimization: { runtimeChunk: 'single', splitChunks: { cacheGroups: { defaultVendors: { test: /[\\/]node_modules[\\/]/, name: 'vendors', chunks: 'all' } } } } };
Debug
Known issues
breakingDropped support for webpack v2-4 in v4.0.0
fix
Upgrade to webpack v5+, or use templated-assets-webpack-plugin@v3 for webpack v2-4.
affects: >=4.0.0
breakingIn v3.0.0, default publicPath behavior changed: unconfigured publicPath now generates paths without leading slash.
fix
If you rely on absolute paths (/), set webpack output.publicPath explicitly.
affects: >=3.0.0
gotchaPlugin does not export ES modules; CJS only.
fix
Use require() instead of import statements. For ESM projects, use createRequire or transpile.
affects: >=1.0.0
gotchaConfiguration key is 'rules', not 'rule'.
fix
Use rules: [...] in the plugin options object.
affects: >=1.0.0
gotchaWhen using 'test' and 'name' together, 'test' takes precedence.
fix
Use only one of 'name' or 'test' per rule to avoid confusion.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'templated-assets-webpack-plugin'
Package not installed or running in wrong directory.
fix
Run 'npm install templated-assets-webpack-plugin --save-dev' or check node_modules path.
TypeError: TemplatedAssetsWebpackPlugin is not a constructor
Using default import syntax with CJS package.
fix
Use require('templated-assets-webpack-plugin') instead of import.
Error: Template rule 'name' must be a string or array of strings
Providing a single string as 'name' is fine, but other types (e.g., object) cause this error.
fix
Ensure each rule's 'name' is a string or array of strings.
webpack v5: Compilation.hooks.processAssets is not a function
Plugin version incompatible with webpack v5 (using v1 or v2).
fix
Upgrade to templated-assets-webpack-plugin@v3 or v4 for webpack v5 support.
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
webpackrequiredPeer dependency for plugin integration; v4 requires webpack 5+, v3 requires webpack 2-5.
Agent activity
8 hits · last 30 days
node
8
Resources
templated-assets-webpack-plugin — npm install templated-assets-webpack-plugin · libregistry