GithubHelp home page GithubHelp logo

qiniu-oss-webpack-plugin's Introduction

qiniu-oss-webpack-plugin

支持 Webpack5 的七牛云存储 webpack 插件,兼容webpack4

之前项目使用的是 https://github.com/longtian/qiniu-webpack-plugin 但webpack5插件进制改动蛮大的,所以我做了升级,并兼容了webpack4,目前用法和原来的一样

安装

npm install qiniu-oss-webpack-plugin --save-dev

引入

const QiniuOssPlugin = require('qiniu-oss-webpack-plugin');

配置

  • ACCESS_KEY,SECRET_KEY, bucket 与七牛云设置一致
  • path 存储的路径,默认为 [hash]
  • include 可选项。你可以选择上传的文件,比如['main.js']``或者[/main/]`

另外

  • Webpack 的 output.publicPath 要指向七牛云(或自定义的)域名地址
// 这里配置 Plugin

// 这里是 Webpack 的配置
module.exports={
 output:{
    // 这里是七牛的域名加上 Webpack 的 hash
    publicPath:"http://abc.com/foo/bar/"
    // ..
 },
 plugins:[
   new QiniuOssPlugin({
      ACCESS_KEY: qiniu.accessKey,
      SECRET_KEY: qiniu.secretKey,
      bucket: qiniu.bucket,
      //上传目录的第一级目录前千万不要有"/" 巨坑
      path: 'web/static/',
      //要上传的文件匹配规则
      include: [/\.js$/, /\.js.gz$/, /\.css$/, /\.css.gz$/],
      //exclude 考虑后期支持
    }),
   // ...
 ]
 // ...
}

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.