🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@sohu-bpd/unplugin-cdn-upload

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sohu-bpd/unplugin-cdn-upload

Upload built assets to a CDN and update asset URLs.

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

@sohu-bpd/unplugin-cdn-upload

Upload built assets to a private CDN storage service after the host build output is written.

Features

  • supports Vite, Rollup, webpack, Rspack, and Rolldown through host-specific adapters
  • uploads files from the final build output directory after the corresponding host hook runs
  • filters files with include / exclude rules
  • excludes **/*.html by default
  • signs PUT Object requests with the SCS HMAC-SHA1 flow
  • keeps generated asset references unchanged

Host Support

The package root exports the unplugin factory object. In app config, prefer the host-specific subpaths:

  • @sohu-bpd/unplugin-cdn-upload/vite
  • @sohu-bpd/unplugin-cdn-upload/rollup
  • @sohu-bpd/unplugin-cdn-upload/webpack
  • @sohu-bpd/unplugin-cdn-upload/rspack
  • @sohu-bpd/unplugin-cdn-upload/rolldown

Rsbuild should use the /rspack entry through tools.rspack; there is no separate ./rsbuild export.

Usage

Vite

import { defineConfig } from "vite";
import cdnUpload from "@sohu-bpd/unplugin-cdn-upload/vite";

export default defineConfig({
  plugins: [
    cdnUpload({
      bucket: "frontend-assets",
      prefix: "my-app/2026-03-30",
      host: "http://bjcnc.scs.sohucs.com",
      accessKey: "access-key",
      secretKey: "secret-key",
      concurrency: 3,
      include: ["assets/**"],
      exclude: ["**/*.html"]
    })
  ]
});

Rollup

import cdnUpload from "@sohu-bpd/unplugin-cdn-upload/rollup";

export default {
  plugins: [
    cdnUpload({
      bucket: "frontend-assets",
      prefix: "my-app/2026-03-30",
      host: "http://bjcnc.scs.sohucs.com",
      accessKey: "access-key",
      secretKey: "secret-key"
    })
  ]
};

Other Hosts

  • Use @sohu-bpd/unplugin-cdn-upload/webpack in webpack configs.
  • Use @sohu-bpd/unplugin-cdn-upload/rspack in Rspack configs and in Rsbuild via tools.rspack.plugins.
  • Use @sohu-bpd/unplugin-cdn-upload/rolldown in Rolldown configs.

Rsbuild

import cdnUpload from "@sohu-bpd/unplugin-cdn-upload/rspack";

export default {
  tools: {
    rspack: {
      plugins: [
        cdnUpload({
          bucket: "frontend-assets",
          prefix: "my-app/2026-03-30",
          host: "http://bjcnc.scs.sohucs.com",
          accessKey: "access-key",
          secretKey: "secret-key"
        })
      ]
    }
  }
};

Options

NameDescriptionDefaultRequired
bucketBucket name.-Yes
prefixObject key prefix. Leading and trailing / are removed.""No
hostSCS host or origin such as bjcnc.scs.sohucs.com or http://bjcnc.scs.sohucs.com.-Yes
accessKeyAccess key.-Yes
secretKeySecret key.-Yes
includeGlob rule or glob rule list.["**/*"]No
excludeGlob rule or glob rule list.["**/*.html"]No
computeMd5Whether to send Content-MD5.trueNo
concurrencyMaximum number of concurrent uploads.3No

Behavior

Build output uploads are wired through the host adapters:

  • Vite uploads after closeBundle
  • Rollup and Rolldown upload after writeBundle
  • webpack and Rspack upload after afterEmit

After the relevant host finishes writing output files, the plugin scans the resolved output directory, filters files with include and exclude, and uploads matching files to:

<prefix>/<relative-output-path>

The plugin does not rewrite URLs inside generated files. During upload it prints colored, structured console logs for START, one UPLOADED line per completed upload, SUCCESS, and ERROR. Each UPLOADED line includes the uploaded file size, and the final SUCCESS line includes the total uploaded size with readable units. Uploads run with a bounded concurrency of 3 by default unless overridden by concurrency.

FAQs

Package last updated on 09 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts