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

@dd-code/cdn-upgrading-plugins

v0.1.1

Published

Vite 插件:构建完成后将静态资源上传 CDN,并仅保留 index.html

Readme

cdn-upgrading-plugins

Vite 插件:在静态资源构建完成后执行 CDN 上传命令,并从构建产物中只保留 index.html

功能

  • 在 Vite 构建结束(closeBundle)后执行你配置的上传命令
  • 从使用方项目的 env(如 .env)中读取 VITE_APP_CODE 并传给上传命令
  • 上传完成后删除构建目录下除 index.html 外的所有文件

安装

npm i cdn-upgrading-plugins
# 或
pnpm add cdn-upgrading-plugins

使用方项目准备

  1. 在项目根目录的 .env.env.production 中配置:
VITE_APP_CODE=your_app_code
  1. vite.config.ts 中注册插件并配置上传命令:
import { defineConfig } from 'vite';
import { cdnUpgradingPlugin } from 'cdn-upgrading-plugins';

export default defineConfig({
  plugins: [
    // ... 其他插件
    cdnUpgradingPlugin({
      uploadCommand: 'node scripts/upload-cdn.js',
      // 上传完成后是否删除除 index.html 外的文件,默认 true
      deleteAfterUpload: true,
    }),
  ],
});

配置项

| 选项 | 类型 | 必填 | 说明 | |------|------|------|------| | uploadCommand | string | 是 | 上传 CDN 的完整命令行。支持占位符见下文。 | | deleteAfterUpload | boolean | 否 | 上传完成后是否删除除 index.html 外的文件,默认 true。 |

命令占位符

uploadCommand 中可使用:

  • {{VITE_APP_CODE}}:替换为 env 中的 VITE_APP_CODE
  • {{outDir}}:替换为当前 Vite 构建输出目录的绝对路径(如 dist

同时,插件执行命令时会注入环境变量:

  • VITE_APP_CODE:与 env 中一致
  • VITE_OUT_DIR:构建输出目录绝对路径

示例:

cdnUpgradingPlugin({
  uploadCommand: 'npx your-cdn-cli upload --code {{VITE_APP_CODE}} --dir {{outDir}}',
});

或使用脚本(脚本内通过 process.env.VITE_APP_CODE / process.env.VITE_OUT_DIR 读取):

cdnUpgradingPlugin({
  uploadCommand: 'node scripts/upload-cdn.js',
});

本地开发

npm install
npm run build

License

MIT