Gathering detailed insights and metrics for text-replace-html-webpack-plugin
Gathering detailed insights and metrics for text-replace-html-webpack-plugin
Gathering detailed insights and metrics for text-replace-html-webpack-plugin
Gathering detailed insights and metrics for text-replace-html-webpack-plugin
npm install text-replace-html-webpack-plugin
Typescript
Module System
Node Version
NPM Version
46.2
Supply Chain
97.4
Quality
74.4
Maintenance
100
Vulnerability
99.6
License
JavaScript (88.49%)
HTML (11.51%)
Total Downloads
10,302
Last Day
3
Last Week
17
Last Month
85
Last Year
3,292
39 Commits
1 Forks
7 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.3
Package Id
text-replace-html-webpack-plugin@1.0.3
Unpacked Size
10.08 kB
Size
3.69 kB
File Count
6
NPM Version
5.6.0
Node Version
8.11.4
Cumulative downloads
Total Downloads
Last day
-66.7%
3
Compared to previous day
Last week
-46.9%
17
Compared to previous week
Last month
7.6%
85
Compared to previous month
Last year
310%
3,292
Compared to previous year
This package is intended to be used along with html-webpack-plugin. It can be used to replace text in the html file created by the html-webpack-plugin during the webpack build process. Works only wth webpack@^4
Might be used to import gzipped files (eg. bundle.js.gz) instead of .js (bundle.js) in the index.html generated by HtmlWebpackPlugin.
Install with npm:
1npm install --save-dev text-replace-html-webpack-plugin
You can pass configuration objects in the replacementArray
to text-replace-html-webpack-plugin
.
Allowed values are as follows
This internally uses String.prototype.replace(). See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace for more info
Name | Type | Description |
---|---|---|
regex | {Regular Expression} | The Regular Expression to be used to search |
searchString | {String} | The string to be search and replaced. If regex is also provided, this will be ignored |
replace | {String | function} | Replacement of searchString |
Add plugin to webpack config plugins
. And pass the replacementArray.
1const HtmlWebPackPlugin = require("html-webpack-plugin"); 2var CompressionPlugin = require('compression-webpack-plugin'); 3const TextReplaceHtmlWebpackPlugin = require('text-replace-html-webpack-plugin'); 4const path = require('path'); 5 6const htmlWebpackPlugin = new HtmlWebPackPlugin({ 7 template: path.resolve(__dirname, 'index.html'), 8 filename: "index.html" 9}); 10 11module.exports = { 12 13 mode : 'production', 14 15 output: { 16 path: path.resolve(__dirname, 'output'), 17 filename: '[name].js' 18 }, 19 20 module: { 21 rules: [ 22 { 23 test: /\.js$/, 24 exclude: /node_modules/, 25 use: { 26 loader: "babel-loader" 27 } 28 }, 29 ] 30 }, 31 plugins: [ 32 htmlWebpackPlugin, 33 new CompressionPlugin({ 34 filename: "[path].gz[query]", 35 algorithm: "gzip", 36 test: /\.js$|\.css$|\.html$/ 37 } 38 ), 39 new TextReplaceHtmlWebpackPlugin({ replacementArray : [ 40 { 41 regex : /abcd/ig, 42 replace : 'xyz' 43 }, 44 { 45 //Will give warning, not error. (As error would have stopped the webpack build) 46 regex : /js/ig, 47 searchString : 'def', 48 replace : (match) => match + '.gz' 49 }, 50 { 51 searchString : 'def', 52 replace : 'aaa' 53 }, 54 { 55 //Will give warning, not error. (As error would have stopped the webpack build) 56 searchString : '/index/ig', 57 replace : 'newIndex' 58 } 59 ] 60 }), 61 ] 62}; 63
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
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
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
Reason
66 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-16
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