This webpack plugin provides an ability to save your assets in Redis.
npm install --save-dev webpack5-redis-plugin
In your webpack.config.js
:
const WebpackRedisPlugin = require('webpack5-redis-plugin');
module.exports = {
entry: {
page1: [
'./src/page1/index.js',
],
page2: [
'./src/page2/index.js',
],
},
output: {
filename: 'js/[name].js',
},
// ...
plugins: [
new WebpackRedisPlugin({
config: {
host: 'redis.example.com',
password: 'password',
},
filter: key => key === 'js/page1.js',
transform: (key, content) => Object({
key: key + ':current',
value: content+'suffix',
}),
}),
],
};
This config tells the plugin to filter out everything js/page1.js
and save key value pair in redis db
Redis client configuration. All possible options can be found here.
The callback function filters keys/assets that will be set in Redis:
Function(
key: string
): boolean
key
- the destination file name relative to your output directory.
Default: () => true
The callback function transforms keys and values that will be set in Redis:
Function(
key: string,
content: string
): { key: string, value: string }
key
- the destination file name relative to your output directory.content
- UTF-8 file conent
Default: (key, content) => { key, value: content }