Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lyfeyaj/qn-webpack
Qiniu webpack plugin (七牛 Webpack 插件)
https://github.com/lyfeyaj/qn-webpack
qiniu qiniu-webpack-plugin qn-webpack webpack webpack-plugin
Last synced: 19 days ago
JSON representation
Qiniu webpack plugin (七牛 Webpack 插件)
- Host: GitHub
- URL: https://github.com/lyfeyaj/qn-webpack
- Owner: lyfeyaj
- License: mit
- Created: 2016-11-08T01:45:16.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-10-02T18:34:17.000Z (about 1 year ago)
- Last Synced: 2024-10-11T13:41:58.683Z (about 1 month ago)
- Topics: qiniu, qiniu-webpack-plugin, qn-webpack, webpack, webpack-plugin
- Language: JavaScript
- Homepage:
- Size: 209 KB
- Stars: 40
- Watchers: 5
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Qiniu Webpack Plugin
====================> 上传 Webpack Assets 至 七牛 CDN
## 前提
需要 Node 版本在 v4.0 以上
## 安装
```sh
npm i -D [email protected]
```## 使用方法
支持的配置项:
+ `accessKey` 七牛 AccessKey
+ `secretKey` 七牛 SecretKey
+ `bucket` 七牛存储对象名称
+ `path` 存储路径, 默认为 `[hash]`,也可以指定 hash 长度,如: `[hash:8]`
+ `exclude` 可选,排除特定文件,正则表达式,如: `/index\.html$/`
+ `include` 可选,指定要上传的文件,正则表达式,如: `/app\.js$/`
+ `maxRetryTimes` 可选,最大重试次数,默认 3
+ `batch` 可选,批量上传文件并发数,默认 20
+ `zone` 可选,存储在七牛的机房(华东 `Zone_z0`、华北 `Zone_z1`、华南 `Zone_z2`、北美 `Zone_na0`)***注: Webpack 的 `output.publicPath` 要指向七牛云(或自定义的)域名地址***
```js
// 引入
const QiniuPlugin = require('qn-webpack');// 配置 Plugin
const qiniuPlugin = new QiniuPlugin({
accessKey: 'my-access-key',
secretKey: 'my-secret-key',
bucket: 'my-bucket',
path: '[hash]/'
});// Webpack 的配置
module.exports = {
output: {
// 此处为七牛提供的域名(http://7xqhak.com1.z0.glb.clouddn.com) 加上 path([hash]/)
publicPath: "http://7xqhak.com1.z0.glb.clouddn.com/[hash]/"
// ...
},
plugins: [
qiniuPlugin
// ...
]
// ...
}
```## 效果图
无图无真相 ^\_\^
![Preview](preview.png)
## License
[The MIT License](./LICENSE)