upload-ali-oss-plugin

1.0.1 • Public • Published

upload-ali-oss-plugin

A webpack plugin to upload assets to aliyun oss

一个上传文件到 阿里云osswebpack 插件。

使用

  1. 安装包
$ npm install upload-ali-oss-plugin -D
or
$ yarn add upload-ali-oss-plugin -D
  1. 在 config 文件中引入,添加到 plugins
const AliOssPlugin = require('upload-ali-oss-plugin')

// webpack config, oss 配置
const { OSS } = require('./oss')

new AliOssPlugin({
  region: OSS.REGION,
  accessKeyId: OSS.ACCESS_KEY_ID,
  accessKeySecret: OSS.ACCESS_KEY_SECRET,
  bucket: OSS.BUCKET,
  ossPath: OSS.PREFIX,
})

// oss.js,记得添加到 .gitignore,不要暴露到外网
module.exports = {
  OSS: {
    ACCESS_KEY_ID: 'your key',
    ACCESS_KEY_SECRET: 'your secret',
    BUCKET: 'your bucket',
    REGION: 'oss-cn-shenzhen',
    PREFIX: '要上传到的 oss 目录',
  },
}

options 说明

参数 说明 类型 默认值 是否必填
region 阿里云上传区域 String oss-cn-hangzhou
accessKeyId 阿里云的 accessKeyId String -
accessKeySecret 阿里云的 accessKeySecret String -
bucket 上传到哪个 bucket String -
debug 调试开关 Boolean false
ossPath 上传到 bucket 的哪个目录 String ''(不传则默认根目录)
patterns 需要上传的文件规则 Array
verbose 是否展示详细日志 Boolean true
timeout 上传超时时间 Number 60(单位秒)
overwrite 是否覆盖同名文件 Boolean false

/upload-ali-oss-plugin/

    Package Sidebar

    Install

    npm i upload-ali-oss-plugin

    Weekly Downloads

    1

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    7.83 kB

    Total Files

    5

    Last publish

    Collaborators

    • stonehelei