1.0.2 • Published 5 years ago

aliyun-oss-plugin v1.0.2

Weekly downloads
4
License
MSPL
Repository
github
Last release
5 years ago

Aliyun OSS Plugin

a webpack plugin helps you upload static file to aliyun oss

上传文件到阿里云的 Webpack 插件

Installation

yarn add -D aliyun-oss-plugin
npm i -D aliyun-oss-plugin

Configuration

const AliyunOSSPlugin = require("aliyun-oss-webpack-plugin")

module.exports = {
  output: {
    publicPath: "https://bucket.oss-region.aliyuncs.com/sub-dir"
  },
  plugins: [
    new AliyunOssPlugin({
      accessKeyId: '<access key id>',
      accessKeySecret: '<access key secret>',
      region: '<region name>',
      bucket: '<bucket name>',
      headers: {
        'Cache-Control': 'max-age=31536000'
      },
      ignore: [
        'robots.txt',
        '**/*.js.map',
        /.*\.html$/,
        function(fileName) {
          return fileName === 'service-worker.js'
        }
      ]
    })
  ]
}

Options:

keytypedefaultdescription
accessKeyIdString-will read ALIYUN_OSS_ACCESS_KEY_ID from enviroment if not set
accessKeySecretString-will read ALIYUN_OSS_ACCESS_KEY_SECRET from enviroment if not set
regionString-will read ALIYUN_OSS_REGION from enviroment if not set
bucketString-will read ALIYUN_OSS_BUCKET from enviroment if not set
headersObject-object http headers
internalBooleanfalseupload file using aliyun internal network (if you build project in aliyun same region ecs)
threadsNumber8multithread upload threads
showProgressBooleanfalseshow upload progress
retriesNumber5retry times for each file when upload failed
ignoreString Regexp Function or array contains above-filter some files that not need to upload to oss, String will treaded as glob pattern just like the filter rules in .gitignore, Regexp will match the relative path like 'index.html' and 'js/app.ffffffff.map.js', Function will get file name and return a boolean true to filter not need files.

选项:

keytypedefaultdescription
accessKeyIdString-如果不指定此参数,将从环境变量 ALIYUN_OSS_ACCESS_KEY_ID 中读取
accessKeySecretString-如果不指定此参数,将从环境变量 ALIYUN_OSS_ACCESS_KEY_SECRET 中读取
regionString-如果不指定此参数,将从环境变量 ALIYUN_OSS_REGION 中读取
bucketString-如果不指定此参数,将从环境变量 ALIYUN_OSS_BUCKET 中读取
headersObject-资源的 http 头
internalBooleanfalse使用阿里云内网上传 OSS 文件 (使用同地域的阿里云 ECS 构建项目时使用)
threadsNumber8多线上传的并发数
showProgressBooleanfalse显示上传进度
retriesNumber5文件上传失败时的重试次数
ignoreString Regexp Function 或者上述类型的数组-筛出不需要上传的文件, String 会被当成 glob pattern 处理(类似 .gitignore 的匹配规则), Regexp 匹配像 'index.html' 和 'js/app.ffffffff.map.js' 的相对地址, Function 会被传入文件相对地址,然后返回布尔值 true 来筛出不需要的文件.
1.0.2

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago