npm i @zrcode/vite-zero-env-plugin
Before conversion
<!DOCTYPE html>
<html lang="en"><head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
<env% Alo7-AI@Beta111 %env>
</title>
</head><body>
<div>
<env% VITE_APP_SERVER %env>
</div></body>
</html>
After conversion
<!--zero-env
发布日期:2023/11/9 15:35:17
项目名称:@zrcode/vite-zero-env-plugin
环境:beta
版本:1.1.3
zero-env-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Alo7-AI@Beta111</title>
</head><body>
<div>sadasdasdas222a</div>
</body>
</html>
Type tips:
declare interface EnvDescParams { date: string; mode: string; version: string; name: string; } declare interface ZeroEnvOptions { envPath?: string; //The environment variable file directory defaults to the project root directory indexPath?: string; //The index.html file directory defaults to the project root directory Directory defaultDesc?: boolean; //Whether to use the default environment annotation envDesc?: (params: EnvDescParams) => string; //Environment annotation function, Return string } declare function ZeroEnv(options?: ZeroEnvOptions): Plugin;