1.0.2 • Published 6 years ago

bosupload-loader v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

bosupload-loader

upload resources to bos(Baidu Object Storage) for webpack

License: MIT

Install

npm install --save-dev bosupload-loader

Usage

import img from './imgs/xx.png'
module.exports = {
  module: {
    rules: [
      {
        test: /\.(png|jpe?g|gif|webp)$/,
        use: [
           {
               loader: 'bosupload-loader',
               options: {
                   accountConfig: {
                       credentials: {
                           ak: 'your bos ak, required',
                           sk: 'your bos sk, required'
                       },
                       endpoint: 'your bos endpoint, required',
                       urlPrefix: 'your urlPrefix, required',
                       bucket: 'your bos bucket name'
                  }
              }
          },
          {
            loader: 'url-loader',
            options: {
                // 超过1024byte的资源以外链形式存入bos
                limit: 1024
            }
          }
        ]
      }
    ]
  }
}

Options

NameTypeDefaultDescription
accountConfig{Object}nullbos account config
limit{number}no limitByte limit to save in bos, if exceed, default use file-loader
headers{Object}nulle.g. Cache-Control: max-age=2592000