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 🙏

© 2025 – Pkg Stats / Ryan Hefner

vitejs-plugins

v0.1.5

Published

easy to use vitejs plugins

Readme

Vitejs-plugins

easy to use vitejs plugins

  • 👌 VitePluginAsyncCatch: add try {} catch (e) {} exception capture for async function
  • ⛺️ VitePluginRouters: dynamically generate page routing files based on directory structure
  • 📦 VitePluginStyleImport: styles that reference component libraries on demand
  • 📺 VitePluginFullReload: automatically reload the page when some specific files are modified

Install

yarn add vitejs-plugins

Usage

VitePluginAsyncCatch

It is defined globally in advance to handle the error information returned by the multi-layer asyncAwait function

/**
 * @filePath
 * @functionName
 * @start The number of characters
 * @err reject error info
 **/
window.handleAsyncAwaitError = function (filePath, functionName, start, err) {
  console.info(filePath, functionName, start, err)
}

Reconfigure the vitejs plugin

import { VitePluginAsyncCatch } from 'vitejs-plugins'

export default {
  //.. 
  plugins: [
    VitePluginAsyncCatch({
      includes: ['.tsx', '.ts', '.js', '.jsx'], // default file suffix
      ignores: [], // Some files to be ignore
    })
  ]
}

VitePluginRouters

dynamically generate page routing files based on directory structure

import { VitePluginRouters } from 'vitejs-plugins'

export default {
  //.. 
  plugins: [
    VitePluginRouters({
      watch: true, // set true when development environment 
      pages: join(process.cwd(), './src/pages'), // Pages Folder
      ignore: ['com', 'components', 'utils'], // Folders ignored
      routerPath: join(process.cwd(), './src/router/config.ts') // routing file path
    })
  ]
}

Generated route configuration example, You can manually set the title in the configuration file, which will not be overwritten by subsequent synchronization. Or set it in the form of page note/* * @ title xxx */

export default [
  {
    path: '/finance/account/detail',
    component: () => import('@/pages/finance/account/detail'),
    resCode: 'finance_account_detail',
    title: '--',
  },
]

VitePluginStyleImport

styles that reference component libraries on demand. For example, reference the style of the ant d component library on demand

import { VitePluginStyleImport } from 'vitejs-plugins'

export default {
  //.. 
  plugins: [
    VitePluginStyleImport({
      name: 'antd', // component library name
      createImport: createImport, // custom Insert Import Content
    }),
  ]
}

function createImport(component_: string) { // get every component name
  const component = component_.replace(/([A-Z])/g, '-$1').toLowerCase()
  const jsStylePath = `node_modules/antd/es/${component}/style/css.js`
  if (fs.existsSync(join(CWD, jsStylePath))) {
    return `import "antd/es/${component}/style/index.js"`
  } else {
    return ''
  }
}

VitePluginFullReload

automatically reload the page when some specific files are modified.

import { VitePluginFullReload } from 'vitejs-plugins'

export default {
  //.. 
  plugins: [
    VitePluginFullReload(['config/xxx.config.ts']),
  ]
}

the second parameter type is as follows

| Option | Description | Type | Default | | ------------------ | -------------------- | ---------- | ---------------------------------------------- | | delay | delay time | number | 0 | | log | log after reload | boolean | true | | root | Files will be resolved against this path | string | process.cwd() |