Registry / web-framework / express-webpack-assets

express-webpack-assets

JSON →
library0.1.0jsnpmunverified

Express middleware that loads hashed Webpack asset manifests generated by assets-webpack-plugin, exposing asset paths (JS, CSS, etc.) to templates via a `webpack_asset()` helper. Version 0.1.0 is the latest stable release. It supports single or multiple JSON manifest files (merged in filesystem order). Useful for referencing versioned assets without hardcoding hashes. Not actively maintained; alternatives include webpack-manifest-plugin with express middleware.

npm install express-webpack-assets
INSTALL
IMPORT
SIG · EXPRESS-WEBPACK-AS
E
express-webpack-assets
web-frameworkjavascriptv0.1.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.

default
✓ import webpackAssets from 'express-webpack-assets'
✗ const webpackAssets = require('express-webpack-assets')
ESM import works as the module has a default export.
webpack_asset
✓ <!-- Available in template locals after middleware is applied: webpack_asset('one', 'js') -->
✗ Using webpack_assets (plural) instead of webpack_asset (singular)
The helper is injected as a local variable named 'webpack_asset'.
options
✓ app.use(webpackAssets('./config/webpack-assets.json', { devMode: false }))
✗ app.use(webpackAssets({ path: './config/webpack-assets.json' }))
The first argument is a path string, not an options object.

Sets up Express middleware to load a webpack assets JSON file and expose the `webpack_asset` helper in templates.

import express from 'express'; import webpackAssets from 'express-webpack-assets'; const app = express(); app.set('view engine', 'ejs'); // Load asset manifest and inject webpack_asset helper into res.locals app.use(webpackAssets('./config/webpack-assets.json', { devMode: false })); app.get('/', (req, res) => { // In the EJS template, use: <script src="<%= webpack_asset('one', 'js') %>"></script> res.render('index'); }); app.listen(3000);
Debug
Known issues
gotchaWhen passing a directory path, the order of merging JSON files is determined by filesystem read order (not alphabetical), which can cause unexpected overrides.
fix
Use a single JSON file or ensure unique property names across files.
affects: >=0.0.0
gotchaThe `webpack_asset` helper is attached as a local variable to Express `res.locals`, so it is only available in templates that are rendered from the same response context.
fix
Access the helper only within templates rendered after the middleware runs.
affects: >=0.0.0
deprecatedThe package is no longer actively maintained; consider using webpack-manifest-plugin with a custom Express middleware.
fix
Migrate to a more modern asset management solution.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot read property 'js' of undefined
The asset key or file type does not exist in the loaded manifest JSON.
fix
Verify the manifest file contains the expected asset keys (e.g., 'one') and file types (e.g., 'js').
Error: ENOENT: no such file or directory, open './config/webpack-assets.json'
The path provided to the middleware does not point to an existing file or directory.
fix
Ensure the path is correct relative to the project root or use an absolute path.
webpack_asset is not defined
The middleware did not run before the template rendering, or the path is invalid causing the helper not to be injected.
fix
Ensure `app.use(webpackAssets(...))` is placed before any route handlers that render templates.
TypeError: webpackAssets is not a function
Importing the module incorrectly (e.g., using named import instead of default import).
fix
Use `import webpackAssets from 'express-webpack-assets'` or `const webpackAssets = require('express-webpack-assets').default` in CommonJS.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
expressoptionalPeer dependency for Express middleware
assets-webpack-pluginrequiredRequired to generate the webpack-assets.json manifest file
Agent activity
4 hits · last 30 days
node
4
Resources
express-webpack-assets — npm install express-webpack-assets · libregistry