https://github.com/zackify/webpack-force-hash-plugin
Only changes the vendor hash if needed
https://github.com/zackify/webpack-force-hash-plugin
Last synced: 5 months ago
JSON representation
Only changes the vendor hash if needed
- Host: GitHub
- URL: https://github.com/zackify/webpack-force-hash-plugin
- Owner: zackify
- Created: 2017-03-15T03:26:17.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-15T06:05:37.000Z (almost 9 years ago)
- Last Synced: 2024-05-21T11:19:21.171Z (almost 2 years ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## webpack-force-hash-plugin
If you use an env variable in your webpack output:
```js
output: {
path: 'public/',
filename: `app.${process.env.COMMIT_HASH || 'dev'}.[name].js`,
chunkFilename: `${process.env.COMMIT_HASH || 'dev'}.[id].chunk.js`,
publicPath: '/',
}
```
Then your vendor bundle is going to have a changed hash even when its not changed. This solves that problem but always using webpack's hash for the file name. Is this something you should be doing? Maybe not. I couldn't think of a way to keep the vendor from changing other than building this little plugin, or getting rid of the commit hash for everythig else.
## Install
```
npm install webpack-force-vendor-hash-plugin
```
## Usage
```js
const ForceHashPlugin = require('webpack-force-hash-plugin');
plugins: [
new ForceHashPlugin({ name: 'vendor' }), // name of the entry point
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
}),
],
```
## Why you should not use this
- You should probably just use webpack's hash and not a commit hash
- This doesn't feel right ;)