Home

Awesome

基于webpack的阿里云OSS上传loader

安装

$ npm install --dev alioss-upload-loader

or

$ yarn add -dev alioss-upload-loader

使用方法

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即可

参数介绍