Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/packingjs/replace-hash-webpack-plugin
This is a webpack plugin that update script references in HTML files by webpack bundle's hash.
https://github.com/packingjs/replace-hash-webpack-plugin
Last synced: 30 days ago
JSON representation
This is a webpack plugin that update script references in HTML files by webpack bundle's hash.
- Host: GitHub
- URL: https://github.com/packingjs/replace-hash-webpack-plugin
- Owner: packingjs
- Created: 2016-05-11T04:25:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-26T06:43:03.000Z (almost 7 years ago)
- Last Synced: 2024-10-28T16:43:35.241Z (2 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 6
- Watchers: 2
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Replace Hash Webpack plugin
[![NPM](https://nodei.co/npm/replace-hash-webpack-plugin.png)](https://nodei.co/npm/replace-hash-webpack-plugin/)
This is a [webpack](http://webpack.github.io/) plugin that update script references in HTML files by webpack bundle's hash.
It uses the [glob](https://github.com/isaacs/node-glob) library to do files matching.
## Installation
Install the plugin with npm:
```shell
$ npm install replace-hash-webpack-plugin --save-dev
```## Configuration
You can pass a hash of configuration options to `ReplaceHashWebpackPlugin`.
Allowed values are as follows:- `cwd`: The current work directory.
- `src`: The original pattern the minimatch object represents.
- `dest`: Dest files save path.
- `pattern`: {Array} (optional) Find and replace rules.
- `exts`: {Array} (optional) Asset types to be replaced. Default: ['js', 'css']## Example
```javascript
//webpack.config.js
var ReplaceHashWebpackPlugin = require('replace-hash-webpack-plugin');
var webpackConfig = {
entry: 'main.js',
output: {
filename: '[name]-[hash:8].js',
publicPath: 'http://www.cdn.com/js/',
},
plugins: [
new ReplaceHashWebpackPlugin({
cwd: 'static',
src: '**/*.jade',
dest: 'prd',
}),
// new ReplaceHashWebpackPlugin({
// cwd: process.cwd() + '/static',
// src: '**/*.html',
// dest: process.cwd() + '/prd',
// exts: ['png', 'jpg', 'jpeg'],
// pattern: [
// {
// find: '([\'"])([/]?%s)(["\'])',
// replace: '$1%s$3'
// }
// ]
// }),
]
};
``````html
replace-hash-webpack-plugin
```
#### result:
```html
replace-hash-webpack-plugin
```