Skip to content

BigMurry/gulp-oss-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-oss-sync

A gulp plugin to sync files with Aliyun OSS

Inspired by gulp-awspublish

NPM

Introduction

Use local cache file to store last published file path and file hash. If the file is in the cache file and the hash is unchanged, then ignore this file.

Screen shots

screen shot

Features

  • Use cache file to save network traffic
  • Automatic delete useless file in OSS

How to use

const gulp = require('gulp');
const ossSync = require('gulp-oss-sync');

const ossConf = {
  connect: {
    "region": "<your oss region>",
    "accessKeyId": "<your access key id here>",
    "accessKeySecret": "<your access key secret kere>",
    "bucket": "<your bucket name here>"
  },
  controls: {
    "headers": {
      "Cache-Control": "no-cache"
    }
  },
  setting: {
    dir: "foo/bar", // root directory name
    noClean: false, // compare with the last cache file to decide if the file deletion is need
    force: false, // ignore cache file and force re-upload all the files
    quiet: true, // quiet option for oss deleteMulti operation
    fileName: (path)=> { return path } // modify oss file path
  }
};
const cacheConf = {
  cacheFileName: '.oss-cache-test' // the filename for the cache file
};

gulp.task('publish', function () {
  return gulp.src(['**/*.png'])
    .pipe(ossSync(ossConf, cacheConf));
})

About

A gulp plugin to sync files with Aliyun OSS

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published