whh

webpack-html-hash-plugin

Inline Hash Webpack Plugin

Showing:

Popularity

Downloads/wk

1

GitHub Stars

7

Maintenance

Last Commit

4yrs ago

Contributors

1

Package

Dependencies

1

Size (min+gzip)

153.2KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Inline Hash Webpack Plugin

Automatically replace the html link and script tags, add hash

Getting Started

Installation

$ npm i webpack-html-hash-plugin

Basic Usage

Step1:

// add hash
output: {
  filename: '[name].js?v=[hash:6]',
  // or [name].[hash].js
  chunkFilename: '[id].js?v=[hash:6]',
  // or id].[hash:6].js
},

Step2:

// webpack.config.prod.js

import WebpackHtmlHashPlugin from 'webpack-html-hash-plugin';
//...
plugins: {
  new WebpackHtmlHashPlugin({
    fileName: 'test.html',
    template: 'template/test.html',
    encoding: 'GBK'
  })
}

or

module.exports = {
  entry: {
    // ...
  },
  output: {
    // ...
  },
  htmlHashOption: {
    fileName: 'test.html',
    template: 'template/test.html',
    encoding: 'GBK'
  }
}
  • template is requisite, template path
  • fileName is not requisite, default index.html
  • encoding is not requisite, default utf-8

webpack version < 2.0 , use new WebpackHtmlHashPlugin.default()

template

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Demo</title>
  <link rel="stylesheet" href="index.css" />
</head>
<body>

<div id="root"></div>

<script src="common.js"></script>
<script src="index.js"></script>

</body>
</html>

build:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Demo</title>
  <link rel="stylesheet" href="index.css?v=4475fb" />
</head>
<body>

<div id="root"></div>

<script src="common.js?v=4475fb"></script>
<script src="index.js?v=4475fb"></script>

</body>
</html>

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100