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

vite-plugin-auto-deploy-plus

v1.4.3

Published

Vite 自动部署插件

Readme

vite-plugin-auto-deploy-plus

一个针对 Vite 项目的自动部署与回滚插件。支持在打包完成后备份远程旧版本、上传新版本,并提供交互式确认与命令行回滚能力。

特性

  • 打包完成后自动提示是否部署,避免误操作
  • 自动备份旧版本,保留多份时间戳归档
  • 支持 scp / rsync 传输方式与 SSH 私钥登录
  • 允许自定义构建输出目录、无交互部署等行为
  • 提供 CLI vite-deploy rollback 一键回滚最新备份

安装

pnpm add -D vite-plugin-auto-deploy-plus
# 或者使用 npm / yarn

使用方法

vite.config.ts

import { defineConfig } from 'vite';
import viteAutoDeploy from 'vite-plugin-auto-deploy-plus';

export default defineConfig({
  plugins: [
    autoDeploy({
				// 👇 填写你的服务器ip和项目存放路径(必填项)
				remoteIp: 'xxx.xx.xxx.xxx', // 服务器 IP 地址
				remoteDir: '/app/project', // 服务器上存放项目的目录(如 /app/project) 则会把打包的dist文件夹放在/app/project项目下
				// 👇 可选配置
				remoteUser: 'root', // 服务器用户名(默认 root)
				remotePort: '22', // SSH 端口(默认 22)
				backupDir: '', // 备份目录(默认自动生成)
				privateKey: '/Users/yourname/.ssh/id_rsa', // 若用密钥登录,填写私钥路径 也可以自己生成上传至服务器 否则每次上传文件的时候服务器都会要求输入密码
				transport: 'scp', // 传输方式(scp 或 rsync,默认 scp)
			}),
  ],
});

执行打包命令(例如 pnpm build)后,终端会询问是否立即部署:

构建已完成,是否立即部署到远程服务器? (y/N):
  • 输入 yyes 即部署并执行备份
  • 直接回车或输入其他内容会跳过部署
  • 若需要在 CI 等非交互环境自动部署,可将 autoConfirm 设为 true

配置项

| 选项 | 类型 | 默认值 | 说明 | | -------------- | ------------------- | -------------------------- | ---- | | remoteIp | string | — | 服务器 IP(必填) | | remoteDir | string | — | 服务器部署目录(必填) | | remoteUser | string | root | SSH 用户名 | | remotePort | string | 22 | SSH 端口 | | backupDir | string | ${remoteDir}_backups | 服务器备份目录 | | transport | 'scp' \| 'rsync' | scp | 上传方式 | | privateKey | string | — | SSH 私钥路径 | | localDist | string | Vite build.outDirdist | 本地构建目录 | | autoConfirm | boolean | false | 是否跳过交互直接部署 |

回滚操作

  1. 确保项目中已正确配置插件(与部署时使用的配置一致)。
  2. 在项目根目录执行:

CLI 将自动读取 vite.config.[ts|js] 中的插件配置,列出备份并默认回滚到最新备份。

如果 Vite 配置文件不在项目根目录,可通过 --config 指定:

也可以在 package.json 中添加脚本,方便日常使用:

{
  "scripts": {
    "rollback": "vite-deploy rollback"
  }
}

之后执行 pnpm run rollback / npm run rollback 即可触发回滚。

也可以在代码中手动调用:

import { rollback } from 'vite-plugin-auto-deploy-plus';

await rollback({
  remoteIp: '1.2.3.4',
  remoteDir: '/var/www/app',
});

仅当远程服务器中存在通过插件生成的备份文件时,回滚才会生效。