Git Product home page Git Product logo

umi-plugin-alioss's Introduction

umi-plugin-alioss

umi,umi-plugin,alioss

基于 umi2.x 插件体系编写

说明

基于umi-plugin系统封装的一个插件,用于构建成功之后上传静态资源到阿里云

使用

yarn add umi-plugin-alioss -D
yarn add ali-oss -D

.umirc.js或者config/config.js中使用

const ossPluginOpt = {
  ossConfig: {
    region: 'oss-cn-beijing',
    bucket: 'example',
    secure: true,
  },
  configName: '.alioss',
  enabled: true,
  cdnPrefix: 'https://cdn.xxx.com/release/', // CDN前缀
  uploadPath: '/release', // 文件上传路径
  exclude: '', // 排除文件
  ignoreHtml: true, // 不上传html
};

export default {
  plugins: [['umi-plugin-alioss', ossPluginOpt]],
};

注意事项:

为了安全起见,alioss上传是需要accessKeyId,accessKeySecret的 我们在使用之前需要先到系统用户目录下新建.alioss文件,内容如下

accessKeyId=1231231231231
accessKeySecret=12312312312313

比如mac用户在/User/xxx/.alioss

windows用户在C:/User/admin/.alioss

注意:在服务器环境中需要给该文件设置读取权限比如:chmod 600 .alioss

1.0.2 更新

为了兼容umi3.x代码有些许改动

umi3.x中的插件配置和2.x有一些不同,上诉的配置方法不适用,在3.x中可以:

// config文件
import { defineConfig } from 'umi';

export default defineConfig({
  hash: true,
  antd: {
    dark: true,
  },
  dva: {
    hmr: true,
  },
  ...,
  alioss: {
    ossConfig: {
      buildPath: 'dist/**',
      ...,
    },
    uploadPath: '/',
  },
});

常见错误

The request signature we calculated does not match the signature you provided. Check your key and signing method.

可以参考这里 (貌似是要翻Q)


The OSS Access Key Id you provided does not exist in our records

检查上述的.alioss,文件中accessKeySecret=accessKeyId=后的值不要加上'' "" 或者其他符号

umi-plugin-alioss's People

Contributors

ahwgs avatar dependabot[bot] avatar xlfdyzcs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.