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

@dykj01/vite

v1.0.8

Published

vite

Readme

@dykj01/vite

一个集成了常用 Vite 插件的配置包,为 Vue 3 项目提供开箱即用的开发体验。

特性

  • 🚀 Vue 3 支持 - 内置 Vue 3 和 JSX 支持
  • 📦 自动导入 - 自动导入 Vue API、组件和图标
  • 🎨 图标支持 - 集成 Iconify 图标库
  • 📊 构建分析 - 内置依赖分析工具
  • 🗜️ 代码压缩 - 支持 Gzip 和 Brotli 压缩
  • 🔄 热更新通知 - 自动检测版本更新并提示用户刷新
  • 🛠️ 开发工具 - 集成 Vue DevTools
  • 📋 VXE Table - 支持 VXE Table 懒加载
  • 🖼️ SVG 加载 - 内置 SVG 加载器

安装

pnpm add @dykj01/vite
# 或
npm install @dykj01/vite
# 或
yarn add @dykj01/vite

基础使用

在你的 vite.config.ts 中:

import { defineConfig } from 'vite'
import { loadApplicationPlugins } from '@dykj01/vite'

export default defineConfig(async ({ command }) => {
  const isBuild = command === 'build'
  
  return {
    plugins: await loadApplicationPlugins({
      isBuild,
      // 其他配置选项...
    })
  }
})

配置选项

ApplicationPluginOptions

| 选项 | 类型 | 默认值 | 描述 | |------|------|--------|------| | isBuild | boolean | - | 是否为构建模式 | | devtools | boolean | false | 是否开启 Vue DevTools | | injectMetadata | boolean | true | 是否注入元数据 | | visualizer | boolean \| PluginVisualizerOptions | false | 是否开启依赖分析 | | webUpdateNotice | boolean | false | 是否开启版本更新通知 | | vxeTableLazyImport | boolean | false | 是否开启 VXE Table 懒加载 | | compress | boolean | false | 是否开启代码压缩 | | compressTypes | ('brotli' \| 'gzip')[] | ['gzip'] | 压缩类型 | | autoImport | boolean | true | 是否开启自动导入 | | autoImportOptions | AutoImportOptions | - | 自动导入配置 | | autoImportComponents | boolean | true | 是否开启组件自动导入 | | autoImportComponentOptions | AutoImportComponentOptions | - | 组件自动导入配置 | | autoImportIcons | boolean | true | 是否开启图标自动导入 | | autoImportIconsOptions | IconsOptions | - | 图标自动导入配置 | | svgLoader | boolean | false | 是否开启 SVG 加载器 | | svgoConfig | Record<string, any> | - | SVGO 配置 |

使用示例

完整配置示例

import { defineConfig } from 'vite'
import { loadApplicationPlugins } from '@dykj01/vite'

export default defineConfig(async ({ command }) => {
  const isBuild = command === 'build'
  
  return {
    plugins: await loadApplicationPlugins({
      isBuild,
      // 开发工具
      devtools: !isBuild,
      
      // 构建优化
      compress: isBuild,
      compressTypes: ['gzip', 'brotli'],
      visualizer: isBuild,
      
      // 更新通知
      webUpdateNotice: isBuild,
      
      // 自动导入
      autoImport: true,
      autoImportComponents: true,
      autoImportIcons: true,
      
      // SVG 支持
      svgLoader: true,
      
      // VXE Table 懒加载
      vxeTableLazyImport: true,
      
      // 自定义配置
      autoImportOptions: {
        imports: ['vue', 'vue-router', '@vueuse/core'],
        dts: true
      },
      
      autoImportComponentOptions: {
        dirs: ['src/components'],
        dts: true
      },
      
      autoImportIconsOptions: {
        autoInstall: true,
        compiler: 'vue3'
      }
    })
  }
})

最小配置

import { defineConfig } from 'vite'
import { loadApplicationPlugins } from '@dykj01/vite'

export default defineConfig(async ({ command }) => {
  return {
    plugins: await loadApplicationPlugins({
      isBuild: command === 'build'
    })
  }
})

开发环境配置

import { defineConfig } from 'vite'
import { loadApplicationPlugins } from '@dykj01/vite'

export default defineConfig(async ({ command }) => {
  const isBuild = command === 'build'
  
  return {
    plugins: await loadApplicationPlugins({
      isBuild,
      devtools: !isBuild, // 仅在开发环境启用
      autoImport: true,
      autoImportComponents: true,
      autoImportIcons: true
    })
  }
})

生产环境配置

import { defineConfig } from 'vite'
import { loadApplicationPlugins } from '@dykj01/vite'

export default defineConfig(async ({ command }) => {
  const isBuild = command === 'build'
  
  return {
    plugins: await loadApplicationPlugins({
      isBuild,
      compress: isBuild, // 仅在生产环境压缩
      compressTypes: ['gzip', 'brotli'],
      visualizer: isBuild, // 仅在生产环境分析
      webUpdateNotice: isBuild // 仅在生产环境启用更新通知
    })
  }
})

内置插件

本包集成了以下 Vite 插件:

  • @vitejs/plugin-vue - Vue 3 单文件组件支持
  • @vitejs/plugin-vue-jsx - Vue 3 JSX 支持
  • vite-plugin-vue-devtools - Vue 开发工具
  • unplugin-auto-import - API 自动导入
  • unplugin-vue-components - 组件自动导入
  • unplugin-icons - 图标自动导入
  • vite-plugin-compression - 代码压缩
  • vite-svg-loader - SVG 加载器
  • rollup-plugin-visualizer - 依赖分析
  • @plugin-web-update-notification/vite - 版本更新通知
  • vite-plugin-lazy-import - VXE Table 懒加载

类型支持

本包提供完整的 TypeScript 类型定义,你可以在项目中享受完整的类型提示。

import type { ApplicationPluginOptions } from '@dykj01/vite'

const config: ApplicationPluginOptions = {
  isBuild: true,
  // 其他配置...
}

许可证

MIT

作者

dykj01 [email protected]