gulp-spsave : Save files to SharePoint using Gulp

Upload files to SharePoint using gulp-spsave

Gulp

automate-tasks-gulpjs

For those who are new to Gulp, Gulp is node based task runner which prefers code over configuration. Gulp has watcher inbuilt. Hence it can automatically watch for any changes in file.

Upload Files to SharePoint

Two impressive gulp plugins are available would facilitate uploading of files to SharePoint. We will talk about spsave in this post.

 

Gulp-SPSave

Spsave is simple yet powerful plugin developed by s-kainet to upload files directly to SharePoint.  Below is a simple implementation of the same:

gulp.task(“copyToSharePoint”, [“buildJS”], function(){

return gulp.src(“./build/*.js”)

.pipe(spsave({

username: settings.username,

password: settings.password,

siteUrl: settings.siteUrl,

folder: “YourAppAssets/js”

}));

});

 

Where “settings” is the settings file where you can store sensitive information.

Vardhaman Deshpande has integrated this plugin with gulp watcher functions along with other gulp functions to achieve following:

  • Concatenate all js files into single js file
  • Minify js file
  • Rename file to min.js
  • Upload files to SharePoint
  • Watch for any changes in file and upload to SharePoint

 

Following are the plugins that are used in demo:

  • gulp-concat : Used to bundle js files.
  • gulp-uglify : Used to minify the js files
  • gulp-rename : Used to rename the minified file to .min.js
  • gulp-spsave : Used to upload files to SharePoint