extract-hash-webpack-plugin
Extract webpack compiler hash
to generate version.json
file after build in the dest
directory.
Options
You can pass some configuration options to ExtractHashWebpackPlugin
. Allowed values are as follows:
filename
: Version file name. Default toversion.json
.hashLength
: Substring length of compiler hash. Default to value'normal'
which means the wholehash
value itself. You can pass anumber
to get a substring of it. Or pass string'full'
to get value offullHash
.dest
: Version file save path. Default toprocess.cwd()
. Will do mkdir if path doesn't exist.fn
: A function to customize content format of version file to be generated. Default to return a json string of hash with the keyversion
.
Example
Generate file ver.json
in directory path.resolve(process.cwd(), 'prd')
.
;var webpackConfig =entry: 'main.js'output:filename: '[name]-[hash:8].js'publicPath: '/js'plugins:dest: 'prd'filename: 'ver.json'hashLength: 8dest: 'prd'filename: 'ver.xml'hashLength: 8`<xml><version></version></xml>`;
Contents of ver.json
:
Contents of ver.xml
:
[hash:8]