vite-plugin-assets-uploader
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

vite-plugin-assets-uploader

Helps you upload the packaged assets of Vite to the server

install

yarn add vite-plugin-assets-uploader --dev

exapmle

import { defineConfig } from 'vite'
import uploader from 'vite-plugin-assets-uploader'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    uploader({
      enableAlioss: true,
      ossOptions: {
        bucket: 'yourBucket',
        accessKeyId: 'yourAccessKeyId',
        accessKeySecret: 'yourAccessKeySecret',
        region: 'oss-cn-hangzhou',
        roleArn: 'yourRoleArn', // option
      },
    }),
  ],
  base: 'oss path',
})

custom

import { defineConfig } from 'vite'
import uploader from 'vite-plugin-assets-uploader'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    uploader({
      userUpload: (filePath: string, content: Buffer) => {
        return new Promise((reslove) => {
          console.log(filePath, content)
          reslove(null)
        })
      },
    }),
  ],
})

more

  • There are two modes for uploading, one is custom and the other is provided by plugins

internal

  • Currently, only ALI-OSS is supported internally by the plug-in ,All contents under 'assetsDir' will be found and uploaded to the server

custom

  • All contents under 'assetsDir' will be found and pass to your callback function
  • The plugin provides good task scheduling, and logging. You only need to provide the upload function

roadmap

[ ] support cos-nodejs-sdk-v5

[ ] Optimizing Task Scheduling

[ ] Logging increases upload time

Readme

Keywords

none

Package Sidebar

Install

npm i vite-plugin-assets-uploader

Weekly Downloads

16

Version

1.1.0

License

MIT

Unpacked Size

42.7 kB

Total Files

21

Last publish

Collaborators

  • q1797793818