Giter Site home page Giter Site logo

wepy-plugin-resources-cdn's Introduction

wepy-plugin-resources-cdn

npm npm

介绍

由于小程序代码包限制2M,经常会因为代码包超出2M而无法上传代码。一般都是因为图片等资源用得太多而导致包太大,因此我们会把图片放到服务器或CDN中,从而减少包体积。

为了方便把代码包中的图片上传到CDN中,本人开发了wepy-plugin-resources-cdn插件,在打包小程序时会自动把代码中用到的图片上传到指定的CDN中。

特性

  • 支持阿里云oss
  • 支持腾讯云cos
  • 支持又拍云
  • 支持七牛
  • 支持 AWS S3
  • 上传成功后,自动删除dist包中的图片,减少dist体积

注意

  • 暂时只支持wepy
  • 已经在公司项目用上,但是不保证完美,欢迎大家PR

安装

npm i wepy-plugin-resources-cdn --save-dev

配置wepy.config.js

module.exports.plugins = {
    'resources-cdn': {
          driver: 'oss',   //选择使用的云存储
          qiniu: {          //七牛配置
            accessKey: 'xxxxx',
            secretKey: 'xxxxx',
            bucket: 'xxxxx',
            domain: 'http://xxxxx.com'
          },
          upyun: {          //又拍云配置
            service: 'xxxxx',
            name: 'xxxxx',
            password: 'xxxxx',
            domain: 'http://xxxxx.net'
          },
          cos: {            //cos配置
            appId: 'xxxxx',
            secretId: 'xxxxx',
            secretKey: 'xxxxx',
            bucket: 'xxxxx',
            region: 'ap-guangzhou',
            https: true     //开启https
          },
          oss: {            //oss配置
            accessKeyId: 'xxxxx',
            accessKeySecret: 'xxxxx',
            bucket: 'xxxxx',
            region: 'oss-cn-shenzhen',
            secure: true    //开启https
          },
           s3: {            //s3配置
            accessKeyId: 'xxxxx',
            accessKeySecret: 'xxxxx',
            bucket: 'xxxxx',
            region: 'us-east-2',
            domain: 'xxxx'
          },
          config: {
            prefix: 'cdn-wxapp',  //上传前缀
            debugMode: true,      //开启debug
            time: true            //给图片url后面加上`?t=time()`防止重新打包后,因为缓存导致图片没变化
          }
        }
};

License MIT

wepy-plugin-resources-cdn's People

Contributors

maiqingqiang avatar sinchang avatar

Stargazers

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

Watchers

 avatar  avatar

wepy-plugin-resources-cdn's Issues

安全问题

你就直接把key 和 secret这么直接打包里么????

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.