1.0.1 • Published 9 months ago

vite-plugin-qiniu-kodo v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Upload static resources to qiniu kodo during packaging

中文文档

Feature

  • Files that have already been uploaded will not be uploaded
  • Support time path, such as uploadPath/20230101/file
  • The configuration is simple, using the vite outDir path, the same path as uploading to Kodo

Preview

preview

Installation

yarn add -D vite-plugin-qiniu-kodo

or

npm i -D vite-plugin-qiniu-kodo

Basic usage

  1. Register the plugin in vite.config.js
  2. Set base public URL path when served in development or production.
// vite.config.js
import vitePluginQiniuKodo from 'vite-plugin-qiniu-kodo'

export default defineConfig(() => {

    const qiniuConfig = {
        enabled: process.env.NODE_ENV === 'production',
        accessKey: 'XXX',
        secretKey: 'XXX',
        bucket: 'XXX',
        bucketDomain: 'XXX',
        uploadPath: 'XXX',
        zone: 'z2',
        timeAddress: true,
        ignore: ['**/*.html', '**/*.map'],
    }

    return {
        base: qiniuConfig.enabled ? `${qiniuConfig.bucketDomain}`: `./`, // same with webpack public path
        plugins: [vue(), vitePluginQiniuKodo(qiniuConfig)]
    }
})
  1. Build Production
npm/yarn run build

The plugin will upload files of outDir path after bundle.

options

optionsdescriptiontypedefault
accessKeyqiniu oss accessKeystring
secretKeyqiniu oss secretKeystring
bucketqiniu oss bucket namestring
bucketDomainqiniu oss bucket domainstring
uploadPathqiniu oss upload storage file namestring
zonestorage room name, see for details https://developer.qiniu.com/kodo/1671/region-endpoint-fqstring
timeAddressEnable the time path file uploadPath/20230101/fileboolean
ignoreignore file rules, silently upload all static resource files except html(string or array)'**/*.html'
...other parameters to initialize oss, see for details https://developer.qiniu.com/kodo/sdk/nodejsany