@star-fed/nos-webpack-plugin

0.0.3 • Public • Published

NOS Webpack Plugin

Webpack 编译后的文件上传到 NOS

该插件上传功能依赖NOS Node.js SDK,感谢该插件作者。

功能

  • 支持并行上传
  • 支持不重复上传

安装

yarn add @star-fed/nos-webpack-plugin --dev

使用

webpack.config.js

const NosWebpackPlugin = require('@star-fen/nos-webpack-plugin');

const nosUploadConfig = {
	accessKey: 'test',
	accessSecret: 'test',
	endpoint: 'test',
	bucketName: 'test',
	nosPrefix: 'test',
}
module.exports = {
  // ... Webpack 相关配置
  plugins: [
    new NosWebpackPlugin(nosUploadConfig)
  ]
}

或者在项目目录下新建 .nosconfig 文件,并且在 .gitignore 忽略此文件

.nosconfig

module.exports = {
  accessKey: 'nos access key', // required
  accessSecret: 'nos access secret', // required
  bucketName: 'demo-test', // required
  endpoint: 'https://nos-jd.163yun.com', // required
  excludes: ['assets/**.map4', '*.map'],
  prefix: '',
  cdnName: '',
  parallel: 10,
  force: true
}

Options

Name Type Default Required Description
accessKey {String} true NOS Access Key
accessSecret {String} true NOS Secret Key
bucketName {String} true NOS 空间名
endpoint {String} true NOS 不同地域不同配置
excludes {Array[string]} ['.DS_Store'] false 忽略的文件类型
prefix {string} '' false NOS 的二级路径 / 文件夹名
cdnName {string} '' false CDN 域名,代替 bucketName 对外使用
parallel {number} 10 false 同时上传文件数,避免产生大量的并发请求
force {Boolean} false false 是否强制上传,就不检查文件是否存在
usePublicPath {Boolean} true false 设置 webpack publicPath,会使用 cdnName 或者 bucketName + prefix
  • bucketName 不需要不携带通信协议: star-dev-test-server
  • excludes 匹配相关文件或文件夹,详细使用请看: micromatch
    • *.map 不上传文件后缀为 map 的文件
    • assets/**.map 不上传 assets 文件夹下文件后缀为 map 的文件

License

Released under the MIT License.

Readme

Keywords

Package Sidebar

Install

npm i @star-fed/nos-webpack-plugin

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

13 kB

Total Files

6

Last publish

Collaborators

  • chang0022