Skip to content

bjmhe/unplugin-jdoss

unplugin-jdoss

npm version npm downloads

A build plugin based on unplugin that automatically uploads files to JD OSS after build completion.

It supports multiple build tools, including Vite, Webpack, Rspack, Rollup, Rolldown, esbuild and Farm. The plugin integrates @jd/upload-oss-tools and automatically performs uploads in the writeBundle hook, eliminating the need for manual deployment of static assets.

Install

npm i -D -E unplugin-jdoss

Features

  • Automatic OSS Upload - Automatically uploads build artifacts to JD OSS after build completion via the writeBundle hook
  • Multi-Builder Support - Works seamlessly with Vite, Webpack, Rspack, Rollup, Rolldown, esbuild, and Farm
  • Zero Configuration - Integrates with @jd/upload-oss-tools out of the box, no manual deployment needed
  • Build Tool Agnostic - Built on unplugin for universal compatibility across modern build tools
  • Static Asset Deployment - Eliminates the need for manual static asset deployment workflows

Usage

/// vite.config.ts

import path from 'node:path'
import VitePluginJdoss from 'unplugin-jdoss/vite'
import { defineConfig, loadEnv, searchForWorkspaceRoot } from 'vite'

export default defineConfig(({ mode }) => {
  const workspaceRoot = searchForWorkspaceRoot(process.cwd())
  const env = loadEnv(mode, workspaceRoot)

  return {
    base: env.VITE_BASE_URL,
    plugins: [
      mode === 'production' &&
        VitePluginJdoss({
          localFullPath: path.resolve(workspaceRoot, 'dist'),
          access: env.VITE_OSS_ACCESS,
          secret: env.VITE_OSS_SECRET,
          site: 'storage.jd.local',
          cover: true,
          timeout: '30000',
          printCdnFile: false,
          bucket: env.VITE_OSS_BUCKET,
          folder: env.VITE_OSS_FOLDER,
          ignoreRegexp: '',
        }),
    ],
  }
})

Ecology

  • Rollup
  • Vite
  • Webpack
  • Esbuild
  • Rspack
  • Farm
  • Rolldown
  • Bun

License

MIT License © 2026-PRESENT Benjamin He

About

A build plugin based on unplugin that automatically uploads files to JD OSS after build completion.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Contributors

Generated from sxzz/unplugin-starter