Gathering detailed insights and metrics for replace-contenthash-in-file-webpack-plugin
Gathering detailed insights and metrics for replace-contenthash-in-file-webpack-plugin
Gathering detailed insights and metrics for replace-contenthash-in-file-webpack-plugin
Gathering detailed insights and metrics for replace-contenthash-in-file-webpack-plugin
A webpack plugin for replacing a string or hash in a file
npm install replace-contenthash-in-file-webpack-plugin
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
5 Commits
1 Branches
1 Contributors
Updated on Nov 12, 2020
Latest Version
1.0.0
Package Id
replace-contenthash-in-file-webpack-plugin@1.0.0
Unpacked Size
7.31 kB
Size
2.96 kB
File Count
4
NPM Version
6.14.8
Node Version
14.15.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
No dependencies detected.
⚠️This is a fork from the original project https://github.com/jamieconnor/replace-hash-in-file-webpack-plugin#readme. The only difference in here is that I modified the source code to work hashcontent instead
Webpack plugin that can replace content in file(s) after compilation is done. This is useful when you want to replace content in any kind of files(html, css, js etc) which are not processed by loaders.
Use [hash] to insert the compilation hash into the search and replace when it is a string or a method returning a string i.e. not a regex.
This is heavily based off replace-in-file-webpack-plugin
Install the plugin with npm:
1$ npm i replace-hashcontent-in-file-webpack-plugin --save-dev
Add the plugin to your webpack and config as follows:
1 const ReplaceHashContentInFileWebpackPlugin = require('replace-contenthash-in-file-webpack-plugin'); 2 const webpackConfig = { 3 entry: 'index.js', 4 output: { 5 path: __dirname + '/dist', 6 filename: 'index_bundle.js' 7 }, 8 plugins: [ 9 new ReplaceHashInFileWebpackPlugin([{ 10 dir: 'dist', 11 files: ['index.html', 'main.html'], 12 rules: [{ 13 search: /js\/bundle\.*[a-zA-Z0-9]*\.js/, 14 replace: 'js/bundle.[hash].js' 15 },{ 16 search: /@title/, 17 replace: 'page title!' 18 }] 19 }, { 20 dir: 'dist/style', 21 test: /\.html$/, 22 rules: [{ 23 search: /version/ig, 24 replace: '1.0.0' 25 },{ 26 search: '@title', 27 replace: function(match){ 28 29 } 30 }] 31 },{ 32 dir: 'dist/style', 33 test: [/\.css$/, /\.txt/], 34 rules: [{ 35 search: /version/ig, 36 replace: '1.0.0' 37 },{ 38 search: '@title', 39 replace: 'webpack' 40 }] 41 }]) 42 ] 43 };
You can pass an array of configuration options to ReplaceHashInFileWebpackPlugin
. Each configuration has following items:
dir
: Optional. Base dir to find the files, if not provided, use the root of webpack context.files
: Optional. Files in dir
to find for replacement.test
: Optional. Regex expression or Regex expressions array to match files in dir
.rules
: Required. Replace content rules array. Each rule has search
and replace
properties.search
: Required. String or Regex expression used for searching content in files - use [hash] to replace hash in string.replace
: Required. String or funcion used for replacing the searching content - use [hash] to replace hash in string.This project is licensed under MIT.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/5 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More