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/component-resolver

v1.0.0

Published

自动化组件按需导入的工具。

Readme

@vavt/component-resolver

自动化组件按需导入的工具。

它可以:

  • 支持自定义组件名前缀,默认为 Vl
  • 灵活配置样式导入方式(CSS、SCSS 或不导入)。
  • 支持自定义组件路径和样式路径解析器。
  • 提供组件名转换函数,支持自定义命名规则。
  • 与 unplugin-vue-components 等工具无缝集成。

⭐️ 特性

  • 灵活的样式导入:支持 CSS、SCSS,可通过函数自定义导入决策。
  • 自定义解析器:提供 resolveComponentPathresolveStylePath 自定义导入路径。
  • 名称转换:支持组件名和路径名的自定义转换。
  • 易于集成:与 unplugin-vue-components 等工具配合使用。
  • 灵活配置:完整的配置选项,适应不同项目需求。

📦 安装

npm install -D @vavt/component-resolver

🛠️ 使用方法

与 Vue + Vite 集成

  1. 安装 unplugin-vue-components
npm install -D unplugin-vue-components
  1. vite.config.ts 中配置:
import Components from 'unplugin-vue-components/vite';
import { componentsResolver } from '@vavt/component-resolver';

export default defineConfig({
  plugins: [
    Components({
      resolvers: [
        componentsResolver({
          prefix: 'Vl', // 组件名前缀
          libraryName: '@vavt/vue-ui', // 组件库名称
          importStyle: 'css',
        }),
      ],
    }),
  ],
});
  1. tsconfig.json 中添加类型:
{
  "compilerOptions": {
    "types": ["@vavt/vue-ui/dist/global.d.ts"]
  }
}

配置完成后可在模板中直接使用组件:

<template>
  <VlCard>卡片</VlCard>
</template>

<script setup lang="js">
// 无需手动导入
</script>

🧩 配置项

| 参数 | 类型 | 默认值 | 说明 | | ------------------------ | ---------------------------------------- | ------------- | ------------------------ | | prefix | string | 'Vl' | 组件名前缀 | | importStyle | boolean \| 'css' \| 'scss' \| function | 'css' | 是否导入样式 | | libraryName | string | - | 库名,用于构建导入路径 | | componentDir | string | 'dist/es' | ESM 组件入口目录 | | cssDir | string | 'dist/css' | CSS 样式目录 | | scssDir | string | 'dist/scss' | SCSS 样式目录 | | resolveComponentPath | function | - | 自定义组件导入路径解析器 | | resolveStylePath | function | - | 自定义样式导入路径解析器 | | transformComponentName | function | - | 组件名转换函数 | | toPathName | function | toKebabCase | 路径名转换函数 |

更多细节请查看源码 index.ts