0.0.26 • Published 2 years ago

chunkhash-replace-webpack-plugin v0.0.26

Weekly downloads
349
License
ISC
Repository
github
Last release
2 years ago

Chunkhash Replace Webpack Plugin

Build Total Downloads

This plugin is for transforming bundle references in your html files with cache friendly filenames using chunkhashes. Its main use is for processing js file references. CSS files will work too, but chunkhashes are associated with js bundles, so changes to your css will not generate a new chunkhash. For handling CSS bundles I recommend the Content Hash Replace Plugin.

Tip: Just use this plugin for your production/staging builds.

Installation

$ npm install chunkhash-replace-webpack-plugin --save-dev

Example

Webpack.config.js

const path = require('path');
const ChunkHashReplacePlugin = require('chunkhash-replace-webpack-plugin');

module.exports = {
  entry: {
    app: ['./src/app.js'],
    vendor: ['jquery', 'lodash', 'react', 'react-dom']
  },
  output: {
    path: path.join(__dirname, 'dist/static'),
    filename: '[name].[chunkhash].js',
    publicPath: '/static/',
  },
  plugins: [
    new ChunkHashReplacePlugin({
      src: 'index.html',
      dest: 'dist/index.html',
    })
  ]
};

HTML

<!DOCTYPE html>
<html lang="en">
<body>
  <script src="/static/vendor.js"></script>
  <script src="/static/app.js"></script>
</body>
</html>

Output

<!DOCTYPE html>
<html lang="en">
<body>
  <script src="/static/vendor.8c670c84b126bbde6319.js"></script>
  <script src="/static/app.bc9412b20a3d196ac0eb.js"></script>
</body>
</html>
0.0.26

2 years ago

0.0.24

8 years ago

0.0.23

8 years ago

0.0.22

8 years ago

0.0.21

8 years ago

0.0.20

8 years ago

0.0.19

8 years ago

0.0.17

8 years ago

0.0.16

8 years ago

0.0.15

8 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago