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

@yeepay/redundant-files

v0.1.13

Published

Scan Vue projects to find unused .vue files, static assets, and JS/TS files

Readme

redundant-files

用于扫描 Vue 项目中未被引用的文件:.vue 组件、静态资源(图片/字体/媒体)以及 JS/TS 代码文件。

安装

  • 配置私有源(如使用公司私有 registry)
# .npmrc(项目或用户级)
@yeepay:registry=<你的内部registry>
//<你的内部registry>/:_authToken=<TOKEN>
  • 全局安装(推荐命令行直接调用)
npm i -g @yeepay/redundant-files
  • 临时执行(无需安装)
npx @yeepay/redundant-files . --verbose
  • 作为项目脚本(本地开发依赖)
npm i -D @yeepay/redundant-files
# package.json 中添加
# {
#   "scripts": {
#     "unused": "vue-prune . --verbose"
#   }
# }
npm run unused
  • 本地开发(全局链接)
npm link
  • 直接运行(无需链接)
node index.js . --verbose

使用

全局安装/链接后可在任意项目根目录执行:

vue-prune [projectPath] [options]
  • 兼容别名:redundant-files
  • projectPath:项目路径(相对/绝对),默认当前目录 .

常用示例

  • 分析当前目录并输出详细日志:
vue-prune . --verbose
  • 分析指定项目路径:
vue-prune /绝对路径/到/你的项目 --verbose

选项

  • --verbose:打印详细日志(包含引用来源、入口文件等)
  • --output:当存在未使用的 .vue 文件时,将其保存到项目根目录的 unused-vue-files.txt
  • --help-h:显示帮助

检测范围与判定原则

工具会从项目入口文件出发构建“依赖图”,仅将“从入口可达”的文件判定为“已使用”。其余视为“未使用”。

  • 未使用的 .vue 文件
  • 未使用的静态资源(PNG/JPG/SVG/WEBP/AVIF/ICO/字体/音视频等),支持 srcpublic
  • 未使用的代码文件(JS/TS/JSX/TSX/MJS/CJS),自动排除常见配置文件与 .d.ts

入口识别

自动识别以下入口(按出现先后使用):

  • src/main.ts|js|mjs|cjs
  • src/App.vueApp.vue
  • src/router/index.ts|js
  • 兜底:任意包含 createApp(new Vue( 的文件

支持的导入/引用模式

  • 静态导入与导出:import … from '…'export … from '…'(支持多行写法)
  • 裸导入(副作用):import '…'
  • 动态导入:import('…')(支持注释如 /* webpackChunkName */
  • 异步组件:defineAsyncComponent(() => import('…'))
  • Vite 批量导入:import.meta.glob('…')import.meta.globEager('…')
  • AMD 风格:require(['a', 'b'])
  • Webpack:require.context(dir, recursive, regex)
  • Web Worker:new Worker('…')new Worker(new URL('…', import.meta.url))
  • 资源引用(内容内扫描):
    • CSS:url(…)
    • JS/TS/Vue:require('…')import … from '…'new URL('…', import.meta.url)
    • HTML/Vue:src="…"srcset="…"

别名(alias)

会自动从常见配置中读取并合并到内置别名:

  • Vite:alias(对象/数组形式)
  • Webpack/Vue CLI:.set('_', resolve('src'))alias: { '_': resolve('src') }
  • tsconfig.json / jsconfig.jsoncompilerOptions.paths

如需手动调整,可编辑 index.js 中的 options.alias

忽略规则(不会被报告为未使用)

  • 目录:node_modules.gitdistbuildconfig/mock/mocks/__mocks__/
  • 配置文件:vite.config.*vue.config.*vitest.config.*jest.config.*cypress.config.*playwright.config.*postcss.config.*tailwind.config.*babel.config.*eslint.*.eslintrc.*prettier.*commitlint.*
  • 文件名包含 mock(不区分大小写)的文件会被排除
  • .d.ts 文件不参与代码文件检测

发布到 npm(私有作用域)

  1. 包名:@yeepay/redundant-files(已配置)

  2. 访问级别(私有):publishConfig.access: restricted(已配置)

  3. 发布步骤:

npm login
npm publish

若使用私有 registry,请确保 .npmrc 已配置 @yeepay 的 registry 与 _authToken

注意事项

  • 建议使用 Node.js >= 16
  • 超大仓库建议传入项目根路径以减少扫描范围
  • 删除前请人工复核;若有项目特定的忽略需求,可在 index.js 中新增规则