1.2.0 • Published 27 days ago

@puhaha/vite-plugin-upload-oss v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
27 days ago

vite-plugin-upload

实现上传静态资源至七牛云和aws的vite插件,可重复刷新上传和增量更新

特性

  • 支持七牛云
  • 支持亚马逊S3

使用

安装

npm i @puhaha/vite-plugin-upload-oss -D

# 七牛云sdk安装
npm i qiniu -D

配置

公用参数

参数说明类型默认值
sdk必填,各平台提供的sdkobject
sdkNameuploadPlugin插件使用,其他没必要String
accessKey必填String
secretKey必填String
bucket必填String
remoteFilePath非必填,表示服务器远程路径string
filePath必填,本地文件夹路径string
openConfirm非必填,是否打开上传前的提示booleantrue
success非必填,上传成功回调Functionfiles => {}
error非必填,上传失败回调Functionfiles => {}
publicCdnPath必填,cdn基础地址string
enabledRefresh非必填,是否刷新文件booleantrue
uploadTarget必填,打包生成的目录地址sting无默认值,需手动填写path.resolve(__dirname, './dist')
appName必填string项目名称
fileLogPath非必填,日志生成的目录地址stinglog/
env非必填,打包的环境stingdevelopment
suffix非必填,日志版本号string
deleteOldFiles非必填,本地dist目录是否删除已经上传的老文件booleantrue
excludeHtml非必填,是否排除html文件上传booleanfalse
htmlPath非必填,html上传打的路径string
awsDistributionId刷新aws上的资源的失效idstring
deleteEmptyFiles是否删除空的js文件booleanfalse

七牛云

// vite.config.[t|j]s
import qiniu from 'qiniu'
import {qiniuPlugin} from '@puhaha/vite-plugin-upload-oss'
export default ({ command, mode }: ConfigEnv): UserConfig => {
  const isBuild = command === 'build';

  return {
    plugins: [
      isBuild && qiniuPlugin({
        sdk: qiniu
        accessKey: 'xxx',
        secretKey: 'xxx',
        bucket: 'xxx',
        filePath: 'xxx',
        remoteFilePath: '',
        openConfirm: true,
        publicCdnPath: 'http://xxx.xxx.com/',
        enabledRefresh: true
      })                
    ]
  }
}

日志

  • 2022.04.21 支持七牛云
  • 2022.10.11 支持增量更新上传,只上传项目中修改过的文件
  • 2022.10.17 支持增量更新上传,删除本地已经上传过的文件
  • 2023.02.01 支持aws上传以及刷新

感谢

1.2.0

27 days ago

1.1.9

2 months ago

1.1.8

10 months ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.1

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.0

1 year ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago