Registry / devops / webpack-redis-plugin

webpack-redis-plugin

JSON →
library1.1.1jsnpmunverified

A Webpack plugin that saves compiled assets to Redis, supporting Webpack versions 2, 3, 4, and 5. Current stable version is 1.1.1, with low release cadence (last update in 2020). Key differentiators include full cross-version compatibility, customizable filtering and transformation of assets via callback functions, and TypeScript type definitions. Unlike similar plugins that only output to disk or cloud storage, this plugin enables real-time asset serving via Redis for use cases like distributed caching or dynamic asset updates.

npm install webpack-redis-plugin
INSTALL
IMPORT
SIG · WEBPACK-REDIS-PLUG
W
webpack-redis-plugin
devopsjavascriptv1.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

WebpackRedisPlugin
const { WebpackRedisPlugin } = require('webpack-redis-plugin')
const WebpackRedisPlugin = require('webpack-redis-plugin')
The plugin exports an object with the class, not the class directly. Use destructured require or import.
WebpackRedisPlugin
import { WebpackRedisPlugin } from 'webpack-redis-plugin'
import WebpackRedisPlugin from 'webpack-redis-plugin'
This package supports both CJS and ESM, but default import is incorrect. Use named import in ESM.
WebpackRedisPlugin (type)
import type { WebpackRedisPluginOptions } from 'webpack-redis-plugin'
The package exports type definitions. Use `import type` for compile-time only usage.

Configures webpack-redis-plugin to filter for non-empty JS assets and save their SHA1 hash to Redis.

const { WebpackRedisPlugin } = require('webpack-redis-plugin'); const sha1 = require('sha1'); module.exports = { entry: { main: './src/index.js', }, output: { filename: 'js/[name].js', }, plugins: [ new WebpackRedisPlugin({ config: { host: process.env.REDIS_HOST ?? 'localhost', port: 6379, password: process.env.REDIS_PASSWORD ?? '', }, filter: (key, asset) => key.endsWith('.js') && asset.size() > 0, transform: (key, asset) => ({ key: `${key}.hash`, value: sha1(asset.source().toString()), }), }), ], };
Debug
Known issues
gotchaThe `config` object is passed directly to the Node redis client. Ensure you do not expose sensitive credentials in the config (e.g., hardcoded password).
fix
Use environment variables and parser options like `process.env.REDIS_PASSWORD`.
affects: >=1.0.0
gotchaThe plugin emits assets in the `afterEmit` hook, meaning output files are already written to disk. If you expect assets to be only in Redis, you must clean the disk output yourself.
fix
Set `output.clean: true` in Webpack config or delete files via another plugin.
affects: >=1.0.0
deprecatedThe plugin uses `redis` package (v3), which is deprecated in favor of `ioredis`. No migration path provided.
fix
Consider using `ioredis` directly, or fork the plugin to replace the Redis client.
affects: >=1.0.0
gotchaIf `filter` returns `false` for all assets, no connection to Redis is made. However, if `filter` throws, the whole Webpack build fails.
fix
Wrap `filter` body in try/catch or ensure it handles errors gracefully.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'webpack-redis-plugin'
Package not installed or import path incorrect.
fix
Run `npm install --save-dev webpack-redis-plugin` and ensure correct require/import (see imports section).
TypeError: webpackRedisPlugin is not a constructor
Incorrect import: using default import instead of named destructuring.
fix
Replace `const WebpackRedisPlugin = require('webpack-redis-plugin')` with `const { WebpackRedisPlugin } = require('webpack-redis-plugin')`.
Redis connection refused
Redis not running or config host/port incorrect.
fix
Start Redis server or update config: `new WebpackRedisPlugin({ config: { host: '127.0.0.1', port: 6379 } })`.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
webpackrequiredPeer dependency: required to function as a Webpack plugin.
redisrequiredRequired to connect to Redis instance.
Agent activity
9 hits · last 30 days
node
8
Resources
webpack-redis-plugin — npm install webpack-redis-plugin · libregistry