VITE前端在测试环境中显示部署时间和git提交消息

在项目开发过程中难免会有测试环境,但是测试人员总不能一直盯着前端更新哪些内容吧,而且会有前端构建不成功的情况导致测试环境不是最新的,也会误导测试人员,所以我做了个插件用来显示部署的情况

开源地址

项目是开源的,点此进入

快速开始

npm i vite-plugin-deploy-log -D
//vite.config.js
import { createDeployLogPlugin } from "vite-plugin-deploy-log";
...
export default defineConfig({
  plugins: [createDeployLogPlugin()],
  ...
})

//main.js
if (import.meta.env.MODE == "staging") { //仅测试环境下显示
  import("vite-plugin-deploy-log").then(({ showDeployLog }) => {
    showDeployLog();
  });
}


附加功能

//插件可选参数
interface DeployLogPlugin {
    /**
     * 输出的数据文件路径
     * @default "deploy.log"
     */
    outputPath?: string;
    /**
     * git消息输出条目数量
     * @default 10
     */
    gitMsgCount?: number;
}

//调用部署日志数据接口
import { getDeployLogData } from "vite-plugin-deploy-log";
getDeployLogData().then(res=>console.log(res));

//修改显示配置
showDeployLog({
  base: '/admin/',
  path: 'deploy.log',
  zIndex: 10000
});

效果演示

图片[1]-VITE前端在测试环境中显示部署时间和git提交消息-诚哥博客

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容