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

@vavt/vite-plugin-auto-export-components

v2.1.0

Published

Vite插件,自动扫描指定目录下的组件,并生成统一的入口文件。

Readme

🎄 @vavt/vite-plugin-auto-export-components

自动扫描指定目录下的组件,并生成统一的入口文件。

它可以:

  • 将目录名(如 my-componentMyComponent)转换成带有自定义前缀的 PascalCase 组件名(如 VlMyComponent)。
  • 只处理一级目录,且目录中必须存在 index.ts 文件。
  • 在开发过程中自动监听文件变化并更新。
  • 支持自定义扫描目录、输出文件名以及组件前缀。

⭐️ 特性

  • 多框架支持:支持 Vue 和 React(通过 framework 选项切换)。
  • 自动导入与导出:自动导入和导出所有符合规则的组件。
  • 自定义前缀:可以自由配置组件名称的前缀(默认是 Vl)。
  • 热更新:组件新增或删除时自动重新生成入口文件。
  • 默认目录:默认扫描 components 目录。
  • 简单集成:无需复杂配置,可直接与项目集成。

📦 Install

yarn add @vavt/vite-plugin-auto-export-components -D

🛠️ 使用方法

import { autoExportComponents } from '@vavt/vite-plugin-auto-export-components';

export default {
  plugins: [
    autoExportComponents({
      dir: 'components', // 默认为 'components'
      output: 'index.ts', // 默认为 'index.ts'
      prefix: 'Vl', // 默认为 'Vl'
      extra: '', // 默认为空
    }),
  ],
};

📁 示例

假设你的项目目录结构如下:

components/
  card/
    index.ts
  video-player/
    index.ts

Vue (默认)

插件会自动生成一个入口文件(如 components/index.ts),内容如下:

import { VlCard } from './card';
import { VlVideoPlayer } from './video-player';

export * from './card';
export * from './video-player';

const components = [VlCard, VlVideoPlayer];

export default {
  install: (app: App) => {
    components.forEach((c) => app.use(c));
    return app;
  },
};

React

如果配置 framework: 'react',生成的内容如下:

export * from './card';
export * from './video-player';

注意:如果某个目录下没有 index.ts 文件,该目录将不会被处理。

🧩 配置项

| 参数 | 类型 | 默认值 | 说明 | | ----------- | ------------------ | -------------- | ------------------ | | dir | string | 'components' | 需要扫描的目录路径 | | output | string | 'index.ts' | 生成的入口文件名 | | prefix | string | 'Vl' | 组件名称的前缀 | | extra | string | '' | 额外的导入语句 | | framework | 'vue' \| 'react' | 'vue' | 框架类型 |