Gathering detailed insights and metrics for vite-plugin-html-config
Gathering detailed insights and metrics for vite-plugin-html-config
Gathering detailed insights and metrics for vite-plugin-html-config
Gathering detailed insights and metrics for vite-plugin-html-config
@dchicchon/vite-plugin-html-config
a vite html config for script,meta,link and more..
vite-plugin-config-html
This plugin helps us configure html script,meta,link etc.
vite-plugin-xq-multi-input
A vite auto config multi html input plugin.一个根据入口目录扫描目录下的html文件并自动配置为多个html入口的Vite插件。
vite-plugin-html-define
vite plugin to transform html with define config
npm install vite-plugin-html-config
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (89.6%)
HTML (9.42%)
CSS (0.98%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
54 Stars
45 Commits
11 Forks
1 Watchers
2 Branches
6 Contributors
Updated on Mar 23, 2025
Latest Version
2.0.2
Package Id
vite-plugin-html-config@2.0.2
Unpacked Size
17.36 kB
Size
4.39 kB
File Count
6
NPM Version
10.8.1
Node Version
20.16.0
Published on
Aug 31, 2024
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
1
4
This plugin helps us configure additional html
The plugin is based on vite transformIndexHtml hooks.
If we want to distinguish the environment and introduce resources in index.html, we can use this plugin. stand by, favicon url, metas config, link tag config, style tag config, headScripts config,body script config.
node version: >=12.0.0
vite version: >=5.0.0
1yarn add vite-plugin-html-config -D
1// vite.config.js 2import htmlPlugin from 'vite-plugin-html-config' 3 4const htmlPluginOpt = { 5 favicon: './logo.svg', 6 headScripts: [ 7 `var msg = 'head script' 8 console.log(msg);`, 9 { 10 async: true, 11 src: 'https://abc.com/b.js', 12 type: 'module', 13 }, 14 { content: `console.log('hello')`, charset: 'utf-8' }, 15 ], 16 preHeadScripts: [ 17 `var msg = 'pre head script' 18 console.log(msg);`, 19 { 20 async: true, 21 src: 'https://abc.com/b.js', 22 type: 'module', 23 }, 24 { content: `console.log('hello')`, charset: 'utf-8' }, 25 ], 26 scripts: [ 27 `var msg = 'body script' 28 console.log(msg);`, 29 { 30 async: true, 31 src: 'https://abc.com/b.js', 32 type: 'module', 33 }, 34 ], 35 metas: [ 36 { 37 name: 'keywords', 38 content: 'vite html meta keywords', 39 }, 40 { 41 name: 'description', 42 content: 'vite html meta description', 43 }, 44 { 45 bar: 'custom meta', 46 }, 47 ], 48 links: [ 49 { 50 rel: 'stylesheet', 51 href: './style.css', 52 }, 53 { 54 rel: 'modulepreload', 55 href: 'https://cn.vitejs.dev/assets/guide_api-plugin.md.6884005a.lean.js', 56 }, 57 ], 58 style: `body { color: red; };*{ margin: 0px }`, 59} 60 61module.exports = { 62 plugins: [htmlPlugin(htmlPluginOpt)], 63}
We can inject different scripts through different environments
such as:script in head,script in body and more.
in config file
1// vite.config.js 2 3const headScripts = [] 4 5// from app env 6const APP_ENV = 'pro' 7 8const BAIDU_KEY = APP_ENV === 'pro' ? '123123' : 'xxxxxx' 9 10if (APP_ENV === 'pro') { 11 headScripts.push( 12 { 13 src: 'https://xxxxxxx/mito.js', 14 apikey: '123123123123123', 15 crossorigin: 'anonymous', 16 }, 17 { 18 src: 'https://bbbbb.js', 19 } 20 ) 21} 22 23const htmlPluginOpt = { 24 headScripts, 25 metas: [ 26 { 27 name: 'keywords', 28 content: 'vite html meta keywords', 29 }, 30 { 31 name: 'description', 32 content: 'vite html meta description', 33 }, 34 ], 35 links: [ 36 { 37 rel: 'stylesheet', 38 href: './style.css', 39 }, 40 { 41 rel: 'modulepreload', 42 href: 'https://www.google.com/xxx.js', 43 }, 44 ], 45 scripts: [ 46 `var _hmt = _hmt || []; 47(function() { 48 var hm = document.createElement("script"); 49 hm.src = "https://hm.baidu.com/hm.js?${BAIDU_KEY}"; 50 var s = document.getElementsByTagName("script")[0]; 51 s.parentNode.insertBefore(hm, s); 52})();`, 53 ], 54 style: 'body { color: red; };*{ margin: 0px }', 55} 56module.exports = { 57 plugins: [htmlPlugin(htmlPluginOpt)], 58}
build index.html
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite React</title>
<meta name="keywords" content="vite html meta keywords">
<meta name="description" content="vite html meta description">
<link rel="stylesheet" href="./style.css">
<link rel="modulepreload" href="https://www.google.com/xxx.js">
<style> body { color: red; };*{ margin: 0px }</style>
<script src="https://xxxxxxx/mito.js" apikey="123123123123123" crossorigin="anonymous" customTag=""></script>
<script src="https://bbbbb.js"></script>
</head>
<body>
<div id="root"></div>
<script>var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?123123";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();</script>
</body>
</html>
other example
https://github.com/saschazar21/jpeg-butcher/blob/main/vite.config.ts#L30
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 5/27 approved changesets -- score normalized to 1
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
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
23 existing vulnerabilities detected
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