This is a webpack plugin that reversion files to the build directory.
Install the plugin:
npm install --save-dev packing-rev-webpack-plugin
new RevWebpackPlugin([patterns], options)
new RevWebpackPlugin({ cwd: path.join(cwd, assets), src: '**/*.{jpg,png}', dest: path.join(cwd, assetsDist), }),
A pattern looks like:
{ cwd: '', src: '**/*', dest: 'dest' }
src
- is required
- can be a glob
- can be an Array
dest
- is optional
- if not absolute, it's relative to the build root
cwd
- is optional
- The base directory (absolute path!) for reversion
- defaults to process.cwd()
glob
- is optional
- glob options
format
- is optional
- reversion name format
- default value is
[name]-[hash][ext]
algorithm
- is optional
- default value is
sha256
length
- is optional
- default value is
8
var RevWebpackPlugin = require('packing-rev-webpack-plugin');
var path = require('path');
module.exports = {
plugins: [
new RevWebpackPlugin([
{ src: 'from/file.txt', dest: 'dist' },
// {output}/to/file.txt
{ cwd: 'assets', src: 'images/**/*', dest: 'imgs' }
]),
new RevWebpackPlugin([
{ src: ['**/*.png', '!notrev.png'], dest: 'dist' },
// {output}/to/file.txt
{ cwd: 'assets', src: 'images/**/*', dest: 'imgs' }
])
]
};