cache-bust-plugin
npm install cache-bust-pluginnpm install cache-bust-plugintypescript
import {CacheBustPlugin} from "cache-bust-plugin";export const webpackConfig = {
// ... Webpack config
plugins: [
new CacheBustPlugin({
// ... cache-bust-plugin options
})
]
}
`
If the writeToIndexHtml option is used then cache-bust-plugin searches for bundle file names in index.html (located in the root directory of your project) and appends bundle hashes using a query string.
`html
index.html (before cache-bust-plugin) =>
index.html (after cache-bust-plugin) =>
`
If the writeToJson option is used then cache-bust-plugin will write the bundle hashes to a JSON formatted text file.
`json5
{
"app.css": "faa879842aef4070b5563ccdc0016cf8",
"app.js": "faa879842aef4070b5563ccdc0016cf8",
"vendor.js": "e5487614083955d6896b53ac06edaffb"
}
``| Option | Description |
|------------------|--------------------------------------------------------------------------|
| writeToIndexHtml | Add bundle hashes to index.html as a query string using text replacement |
| writeToJson | Write bundle hashes to JSON formatted text file |
| jsonFileName | Used with writeToJson option (defaults to version.json) |