Skip to content
PluginStats

vite-plugin-walle-cos weekly downloads statistics

By choukin · npm · Webpack plugins

Upload Vite or Webpack production assets to Tencent COS

View on npm Fresh · Dec 6, 2026

vite-plugin-walle-cos has 38 recorded weekly downloads on npm, an increase of 245% over the past 30 days, ranking #2840 of 3,247 tracked listings.

Weekly downloads
38
Official API · Dec 5, 2026
7-day growth
+40.7%
+11 weekly downloads
30-day growth
+245%
+27 weekly downloads
90-day growth
+153%
+23 weekly downloads
Rank
#2840
▼ 98 in 7 days

About vite-plugin-walle-cos

vite-plugin-walle-cos

将 Vite 或 Webpack 的生产构建资源上传到 Tencent COS,默认不上传 HTML。

支持范围

  • Vite 2 - 7,支持 ESM 和 CommonJS 配置
  • Webpack 4 / 5
  • Node.js >=12.22.0 <13 或 >=13.2.0(插件运行时;宿主构建工具另有版本要求)
  • 凭证来源:永久密钥、自定义 getAuthorization 或临时密钥接口

插件运行时支持 Node.js >=12.22.0 <13 或 >=13.2.0(不支持 13.0.0–13.1.x);宿主构建工具也必须满足自身的 Node.js 版本要求。例如 Vite 3/4 要求 Node.js 14.18+,Vite 5/6 要求 Node.js 18+,Vite 7 要求 Node.js 20.19+ 或 22.12+。Node.js 12/13 已停止维护;如需使用,应确保宿主构建工具及依赖也支持对应版本。

安装

npm i -D vite-plugin-walle-cos

Vite

import { defineConfig } from 'vite'
import vitePluginWalleCOS from 'vite-plugin-walle-cos'

export default defineConfig({
  base: 'https://static.example.com/app/',
  plugins: [
    vitePluginWalleCOS({
      region: 'ap-beijing',
      bucket: 'example-1234567890'
    })
  ]
})

CommonJS 配置:

const vitePluginWalleCOS = require('vite-plugin-walle-cos')

Webpack 4 / 5

const WebpackPluginWalleCOS = require('vite-plugin-walle-cos/webpack')

module.exports = {
  output: {
    path: require('path').resolve(__dirname, 'dist'),
    publicPath: 'https://static.example.com/app/'
  },
  plugins: [
    new WebpackPluginWalleCOS({
      region: 'ap-beijing',
      bucket: 'example-1234567890'
    })
  ]
}

工作方式

  • Vite:插件只在 build 时生效,于 closeBundle 阶段从磁盘扫描并上传 build.outDir;相对路径按 config.root 解析,上传前缀取 config.base。设置 build.write: false 时跳过上传,避免误传磁盘上残留的旧产物。vite build --watch 的每轮重建都会触发 closeBundle,因此 watch 构建整场跳过,并且只提示一次原因。
  • Webpack:于 afterEmit 阶段上传当前 compilation 的资源;outDir 默认取 output.path,base 默认取 output.publicPath;当 Webpack 未设置该项,或其值为 auto / 空字符串时,上传前缀默认为 /。两者都可用插件参数覆盖。
  • Webpack 触发条件:enabled 是唯一开关 —— false 时不注册上传钩子,true(默认)时不管 Webpack mode 是什么都会上传,development 模式也不例外。唯一例外是 watch 编译(含 dev server):它会反复触发 afterEmit,因此始终跳过并打印一次原因。
  • Webpack 上传范围:只上传当前 compilation 声明的资源,不会重复上传 output.path 中残留的旧文件。
  • HTML 与忽略规则:默认忽略 **/*.html;SSR 客户端构建额外忽略 ssr-manifest.json,SSR 服务端构建忽略全部文件。显式传入 ignore 会替换这些默认规则,而不是追加;例如 ignore: [] 表示不忽略文件。
  • base / publicPath:接受完整的 HTTP(S) URL、// 开头的协议相对地址(按 https 补全,//a.com 这类没有路径的写法同样支持),或任意路径 / 相对前缀(如 /assets/、assets/、correct-center、release:v2/)。相对前缀中冒号后带路径斜杠时按对象键前缀处理;已知的 URI scheme(如 mailto:、file:、data:、https:cdn.example.com/a/)仍会拒绝。上传只依赖路径部分拼出 COS 对象键,域名仅用于日志里打印完整访问地址;没有域名时日志只显示对象键。路径中的百分号编码会解码为 COS 对象键,完整 URL 日志则保留 URL 编码。要改 COS 实际请求的域名,请用 SDK 的 Domain 配置,它和 base 互不影响。
  • closeBundle 顺序:Rollup 3 及以上使用顺序钩子,会等其他 closeBundle 写完后再上传。Rollup 2 不支持顺序钩子配置,只能使用函数钩子,因此不要依赖其他异步 closeBundle 生成的资源;无法探测 Rollup 版本时会告警并回退到这种模式。
  • 空构建:没有待上传文件时直接跳过,不创建 COS 客户端,也不输出上传开始/完成日志。
  • test: true:只打印目标路径,不创建 COS 客户端,也不需要可用凭证。

凭证

按以下顺序决定凭证来源:

优先级条件行为
1显式配置 temporaryCredentials: { ... }使用临时密钥接口,必须提供 endpoint
2未显式配置临时密钥,但提供了 getAuthorization交给自定义回调,插件不请求临时密钥
3未配置以上两项,且提供完整 Credentials 或同时提供 SecretId 和 SecretKey使用永久密钥
4以上都没有进入临时密钥模式,因缺少 endpoint 直接报错

补充说明:

  • Credentials 中的 secretId 和 secretKey 必须同时提供;SDK 的 Credentials 优先于 SecretId / SecretKey。
  • SecretId / SecretKey 也接受小写写法 secretId / secretKey;两种写法同时存在时以大写为准。
  • 只提供 SecretId 或 SecretKey 其中一个会直接报错。
  • temporaryCredentials: false 关闭临时密钥逻辑。
  • temporaryCredentials: true 等价于启用临时密钥但不带任何配置,仍需通过 temporaryCredentials: { endpoint } 提供地址。
永久密钥
{
  region: 'ap-beijing',
  bucket: 'example-1234567890',
  SecretId: process.env.COS_SECRET_ID,
  SecretKey: process.env.COS_SECRET_KEY
}
临时密钥

临时密钥接口地址必须显式提供,不存在内置地址兜底;未提供时上传直接报错。

vitePluginWalleCOS({
  region: 'ap-beijing',
  bucket: 'example-1234567890',
  temporaryCredentials: {
    endpoint: 'https://gateway.example.com/cos/credential'
  }
})

请求方法仅支持 GET(默认)和 POST,接口地址必须是 HTTP(S) URL。

默认识别以下响应结构(data 可嵌套最多 3 层):

{
  code: '0',
  data: {
    tmpSecretId,
    tmpSecretKey,
    sessionToken,
    startTime,
    expiredTime
  }
}

字段兼容如下,时间戳支持秒或毫秒(大于等于 1e12 视为毫秒):

字段可接受的键名说明
密钥 IDTmpSecretId / tmpSecretId必填
密钥 KeyTmpSecretKey / tmpSecretKey必填
临时 TokenSecurityToken / sessionToken / XCosSecurityToken必填
生效时间StartTime / startTime缺省为当前时间前 1 秒
过期时间ExpiredTime / expiredTime必填,已过期直接报错

缓存与刷新行为:

  • 到期前 refreshBeforeExpires(默认 60 秒)触发刷新,实际窗口取 min(refreshBeforeExpires, 有效期 / 2),短寿命密钥不会被反复刷新。
  • 并发上传复用同一个请求 Promise。
  • 刷新失败时,只要缓存密钥仍未过期就继续使用,并在 1 - 5 秒内不重复重试;密钥已过期则报错。
  • 接口报错会附带网关返回的 message / msg / error 文本(截断到 200 字),便于定位。

请求方法、参数、请求头、请求体和超时都可以覆盖:

vitePluginWalleCOS({
  region: 'ap-beijing',
  bucket: 'example-1234567890',
  temporaryCredentials: {
    endpoint: 'https://gateway.example.com/cos/credential',
    method: 'POST',
    params: { channel: 'front-end' },
    headers: { 'x-app-id': 'web' },
    data: { scope: 'assets' },
    timeout: 10000,
    refreshBeforeExpires: 60
  }
})

timeout 必须为正数;传入 0、负数或非法值会回退到默认的 10000 毫秒,避免构建在接口无响应时一直挂起。

如需复用 Axios、网关签名或其他请求封装,可传入 request:

import axios from 'axios'

const temporaryCredentials = {
  endpoint: 'https://gateway.example.com/cos/credential',
  method: 'GET',
  params: { channel: 'example-channel' },
  request: async ({ url, method, params, headers, data, timeout }) => {
    const response = await axios({ url, method, params, headers, data, timeout })
    return response.data
  }
}

不同接口响应可通过 transformResponse 转为 SDK 所需字段:

temporaryCredentials: {
  endpoint: 'https://gateway.example.com/cos/credential',
  transformResponse(response) {
    return {
      TmpSecretId: response.result.id,
      TmpSecretKey: response.result.key,
      SecurityToken: response.result.token,
      StartTime: response.result.start,
      ExpiredTime: response.result.expires
    }
  }
}
自定义授权

已有网关或 STS 封装时,可以直接交给 COS SDK:…

Description from the npm listing.

  • vite-plugin
  • webpack-plugin
  • walle-cos
  • tencent

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

vite-plugin-walle-cos weekly downloads on npm, last 90 days: 38 weekly downloads as of Dec 5, 2026, +153% over 90 days.vite-plugin-walle-cosWeekly downloads on npm · Last 90 days38downloads / week+153% over 90 days050100150200250300Sep 6Sep 21Oct 6Oct 21Nov 5Nov 20Dec 5downloads / weekobservedarchived (Internet Archive)no observationsSep 7, 2026 – Dec 5, 2026 · 90 observations · Updated Dec …pluginstats.com
vite-plugin-walle-cos weekly downloads on npm, last 90 days: 38 weekly downloads as of Dec 5, 2026, +153% over 90 days.

7/30/90-day growth

vite-plugin-walle-cos weekly downloads growth on npm: +40.7% over 7 days, +245% over 30 days, +153% over 90 days.vite-plugin-walle-cosWeekly downloads growth on npm38downloads / week now7-day growth+11 weekly downloads+40.7%30-day growth+27 weekly downloads+245%90-day growth+23 weekly downloads+153%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
vite-plugin-walle-cos weekly downloads growth on npm: +40.7% over 7 days, +245% over 30 days, +153% over 90 days.

Ranking history

vite-plugin-walle-cos npm ranking history: currently #2840 (by weekly downloads).vite-plugin-walle-cosnpm ranking · by weekly downloads · Last 90 days#2840current rank#1600#1800#2000#2200#2400#2600#2800#3000Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankNov 16, 2026 – Dec 6, 2026 · 21 observations · Updated Dec 5, 2026pluginstats.com
vite-plugin-walle-cos npm ranking history: currently #2840 (by weekly downloads).

Listing placement

All npm3,247 listings · 163 pages · 1,083 shown · page 143, #2 (overall #2,842)
All npm: every listing in weekly downloads order

Listing placement

Webpack plugins349 listings · 18 pages · page 13, #18 (overall #258)
Webpack plugins: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (135)
Recent weekly downloads observations for vite-plugin-walle-cos
Date (UTC)Weekly downloadsChange vs. previous
38+8
30-1
31+4
270
27+5
22-2
24-3
27+2
25+8
17-6
23-2
25-6
31-182
213—

Similar npm Webpack plugins plugins

All 20 vite-plugin-walle-cos alternatives

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/vite-plugin-walle-cos. First seen Nov 16, 2026; last successful collection Dec 6, 2026. See the methodology.