webpack-aliyun-oss
A webpack plugin to upload assets to aliyun oss
一个webpack插件,上传资源到阿里云cdn
Install
$ npm i webpack-aliyun-oss -S
Options
from
: 从哪里取文件上传,默认为output.path。支持类似gulp.src的glob方法,如'./build/**', 可以为glob字符串或者数组。dist
: 上传到哪个目录下,默认为根目录。region
: 阿里云上传区域accessKeyId
: 阿里云的授权accessKeyIdaccessKeySecret
: 阿里云的授权accessKeySecretbucket
: 上传到哪个bucketdeletOrigin
: 上传完成是否删除原文件,默认falsesetHeaders
: 配置headers
Example
const WebpackAliyunOss = require('webpack-aliyun-oss')
const webpackConfig = {
plugins: [new WebpackAliyunOss({
from: ['./build/**', '!./build/**/*.html'],
dist: 'path/in/alioss',
region: 'your region',
accessKeyId: 'your key',
accessKeySecret: 'your secret',
bucket: 'your bucket',
deleteOrigin: false,
setHeaders(filePath) {
return {
'Cache-Control': 'max-age=31536000'
}
}
})]
}