npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plugin-monitor

v0.2.1

Published

提供获取启动,HMR时间等简单指标,拦截 --debug 下的所有日志的能力

Readme

vite-plugin-monitor

提供获取Vite的启动HMR时间等简单指标,拦截 --debug 下的所有日志的能力

使用

安装依赖

npm install vite-plugin-monitor --dev
# or
yarn add vite-plugin-monitor --dev
# or
pnpm add -D vite-plugin-monitor

激活插件

vite.config.js

import { defineConfig } from 'vite'
import vitePluginMonitor from 'vite-plugin-monitor'

export default defineConfig({
  plugins: [
    vitePluginMonitor({
      // log: false,
      monitor(label, time, originData) {
        const {
          time1, time2, originValue, chalkValue,
        } = originVal
        console.log(originValue)
        console.log(chalkValue)
        console.log(label, time1, time2, `${time}ms`)
      },
      debug(str) {
        // 打印完整日志
        // process.stdout.write(str)
      },
    }),
  ],
})

效果示例

图片

启动说明

在启动参数中加入--debug或者完整的功能支持

{
    "scripts":{
        "serve":"vite --debug"
    }
}

参数描述

| 参数名 | 类型 | 示例 | 说明 | | :-----: | :------: | :---: | :---------------------------------: | | log | Boolean | false | 设置为true将不会打印--debug下的日志 | | monitor | Function | - | 默认回调 | | debug | Function | - | debug回调--拦截debug行为 |

完整定义

/**
 * 插件参数
 */
export interface PluginOptions {
    /**
     * 是否在终端中输出原来的日志
     */
    log?: boolean
    /**
     * 默认回调
     */
    monitor?: MonitorCallback

    /**
     * debug回调
     */
    debug?:DebugCallback
}

/**
 * 原来的日志
 */
export interface OriginDat{
    /**
     * debug日志中的第一个时间(xxms)
     */
    time1?:number
    /**
     * debug日志中的第二个时间(+xxms)
     */
    time2?:number
    /**
     * debug打印的原始内容
     */
    originValue?: string;
    /**
     * debug打印的原始内容(带颜色)
     */
    chalkValue?: string;
}

/**
 * 默认回调函数,对日志做了简单处理
 * @param label 日志类型
 * @param time 消耗时间(time1+time2)
 * @param origin 原日志相关内容
 */
export type MonitorCallback = (label:string, time: number, origin?:OriginDat) => void

/**
 * 拦截debug都打印日志的回调函数
 */
export type DebugCallback = (...argvs:string[]) => void