Gathering detailed insights and metrics for html-webpack-plugin-replaceurl
Gathering detailed insights and metrics for html-webpack-plugin-replaceurl
Gathering detailed insights and metrics for html-webpack-plugin-replaceurl
Gathering detailed insights and metrics for html-webpack-plugin-replaceurl
npm install html-webpack-plugin-replaceurl
Typescript
Module System
Node Version
NPM Version
70.4
Supply Chain
98.8
Quality
75.4
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
11 Stars
36 Commits
2 Watchers
2 Branches
1 Contributors
Updated on Sep 04, 2022
Latest Version
1.1.2
Package Id
html-webpack-plugin-replaceurl@1.1.2
Size
4.46 kB
NPM Version
4.6.1
Node Version
7.1.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
此插件需配合html-webpack-plugin使用,作用是将html文档中对本地静态资源(js/style)的引用替换为经webpack编译后url。
npm install html-webpack-replaceurl-plugin --save-dev
配置webpack:
1let HtmlWebpackPlugin = require('html-webpack-plugin'); 2let HtmlWebpackReplaceurlPlugin = require('html-webpack-replaceurl-plugin'); 3let webpackConfig = { 4 entry: { 5 'main.a':'main.a.js', 6 'vendor': 'vue' 7 }, 8 output: { 9 path: 'dist', 10 publicPath: '/', 11 filename: '[name].[hash].js' 12 }, 13 plugins: [ 14 new webpack.optimize.CommonsChunkPlugin({ 15 name: 'vendor', 16 filename: 'vendor.js' 17 }), 18 new HtmlWebpackPlugin({ 19 inject: false, //此项必须配置为false 20 }), 21 new HtmlWebpackReplaceurlPlugin({ 22 // 解析模式:strict-严格模式;loose-宽松模式 23 mode: 'loose', 24 js: { 25 // 文件名前缀 26 mainFilePrefix: 'main', 27 // 代替换文件名是否包含hash指纹 28 useHash: false, 29 // 文件名分隔符,默认文件名规范为main.[name].js 30 separator: '.', 31 // 是否存在common模块 32 common: true, 33 // dll文件信息 34 dll: { 35 name: 'webapp.dll.js', 36 url: '/js/webapp.dll.js' 37 } 38 }, 39 css: { 40 // 文件名前缀 41 mainFilePrefix: 'main', 42 // 是否使用hash 43 useHash: false, 44 // 文件名分隔符,默认文件名规范为main.[name].css 45 separator: '.' 46 }, 47 // 是否在url末尾加入时间戳,默认false 48 urlTimestamp: false 49 })] 50};
上述配置项应用于index.html文件:
1<!DOCTYPE html> 2<html> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Webpack App</title> 6 <script src="vendor.js"></script> 7 </head> 8 <body> 9 <script src="main.a.js"></script> 10 </body> 11</html>
编译后的index.html内容为:
1<html> 2 <head> 3 <meta charset="UTF-8"> 4 <title>Webpack App</title> 5 <script src="/dist/vendor.js"></script> 6 </head> 7 <body> 8 <script src="/dist/main.a.bc2e63dd.js"></script> 9 </body> 10</html>
loose
-宽松模式,使用正则匹配,准确度略低;strict
-严格模式,解析html文档100%匹配准确度。详细原理请参考boi-资源定位。
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/28 approved changesets -- score normalized to 0
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
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-05-05
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