HtmlCustomHashWebpackPlugin
This is a webpack plugin that works together with another plugin, HtmlWebpackPlugin, to allow you to customize the cache buster parameter for script/style assets.
Why?
HtmlWebpackPlugin can add a cache buster paramter to your style / script tags (when you set hash:true
),
but there's no way to customize that value:
HtmlCustomHashWebpackPlugin allows you to replace that random value with something specific for your build, for example:
Installation
Install the plugin with npm:
$ npm install html-custom-hash-webpack-plugin --save-dev
Usage
Import the plugin in your webpack.config.js file and configure it with the value that you want for the hash (cache buster) parameter:
var HtmlWebpackPlugin = ;var HtmlCustomHashWebpackPlugin = ; moduleexports = entry: 'index.js' output: path: __dirname + '/dist' plugins: template: './index.html' inject: 'body' hash: processenvRC_VERSION ;
Make sure to not provide a hash:true
configuration for HtmlWebpackPlugin.
Contribution
You're free to contribute to this project by submitting issues and/or pull requests.
License
This project is licensed under MIT.