https://github.com/faurewu/webpack-alioss-upload-loader
a webpack loader for alioss upload
https://github.com/faurewu/webpack-alioss-upload-loader
Last synced: 2 months ago
JSON representation
a webpack loader for alioss upload
- Host: GitHub
- URL: https://github.com/faurewu/webpack-alioss-upload-loader
- Owner: FaureWu
- Created: 2018-11-16T01:32:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-27T08:01:33.000Z (over 6 years ago)
- Last Synced: 2025-03-09T13:46:04.208Z (3 months ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 基于webpack的阿里云OSS上传loader
## 安装
```bash
$ npm install --dev alioss-upload-loader
```
or
```bash
$ yarn add -dev alioss-upload-loader
```## 使用方法
```js
module.exports = {
...
module: {
rules: [
{
test: /\.js|.jsx|.scss|.less|.css|.styl?$/,
use: [
{
loader: "alioss-upload-loader",
options: {
accessKeyId: "**************",
accessKeySecret: "*************",
endpoint: "https://***********.aliyuncs.com",
region: "***********",
bucket: "*********",
path: "src/assets/",
formats: ["png", "jpeg", "jpg", "svg"],
prefix: "@oss",
}
}
]
}
]
}
}
```## 使用方法
在监听的文件中,比如我们需要引入图片资源,且希望能上传到oss,图片路径写成@oss/logo.png即可
## 参数介绍
* accessKeyId 必填 阿里云oss key
* accessKeySecret 必填 阿里云oss secret
* endpoint 必填 阿里云oss服务器地址
* region 必填 阿里云oss region
* bucket 必填 阿里云oss bucket
* path 选填 默认值/ 需要上传的资源根路径
* formats 选填 默认值['png', 'jpg', 'jpeg', 'svg', 'bmp', 'gif', 'webp', 'tiff'] 可上传的资源格式
* prefix 选填 默认值@oss 以此为开头的资源引用会被上传到阿里云oss并替换地址