dzed-baradzed
8/30/2017 - 9:57 PM

gulpfile_milestone_legacy.js

legacy solution

{
  "name": "milestone-legacy",
  "version": "1.0.0",
  "private": true,
  "description": "Legacy version of milestone site",
  "author": "Andrei",
  "license": "ISC",
  "devDependencies": {
    "del": "^3.0.0",
    "gulp": "^3.9.1",
    "gulp-cache-bust": "^1.1.0",
    "gulp-chug": "^0.5.1",
    "gulp-replace": "^0.6.1",
    "gulp-sequence": "^0.4.6"
  }
}




var gulp         = require("gulp");
var gulpSequence = require('gulp-sequence');
var cachebust    = require('gulp-cache-bust');
var del          = require("del");
var replace      = require('gulp-replace');
var chug         = require( 'gulp-chug' );

// TASK: default
gulp.task("default", gulpSequence("clean", "cachebusting", "copyfiles", "gulprebuildsolution"));
gulp.task("default2", gulpSequence("clean", "cachebusting", "copyfiles"));

// TASK: watch
gulp.task("watch", function() {

  gulp.watch("Assets/Styles/*.css", function(event) {
    gulpSequence("cachebusting", ["copyviewfile", "copycss"])( function(err) {
      if (err) console.log(err); 
    });
  });

  gulp.watch("Assets/Scripts/*.js", function(event) {
    gulpSequence("cachebusting", ["copyviewfile", "copyjs"])(function(err) {
      if (err) console.log(err); 
    });
  });

});

// TASK: cache busting
gulp.task("cachebusting", function () {
  gulp.src("./Layouts/DefaultWF.aspx", { base: "./" })
  .pipe(cachebust({ type: "timestamp" }))
  .pipe(gulp.dest("./"))
}); 


// TASK: run the gulp file in the rebuild solution
gulp.task("gulprebuildsolution", function() {
  gulp.src('/Users/labaia01/Milestone/Code/DEV/MilestoneDevRebuild/Milestone.Project.Sc/gulpfile.js')
  .pipe( chug({
    tasks: ["default2"]
  }))  
});


// TASK: clean
gulp.task("clean", function() {
  return del([
    "/inetpub/wwwroot/milestone/Website/Milestone/Layouts/DefaultWF.aspx", 
    "/inetpub/wwwroot/milestone/Website/Milestone/Assets/Styles/**/*",
    "/inetpub/wwwroot/milestone/Website/Milestone/Assets/Scripts/**/*"], 
    {force: true});
});


// COPY: default view file
gulp.task("copyviewfile", function() {
  return gulp.src("./Layouts/DefaultWF.aspx")
    .pipe(gulp.dest("/inetpub/wwwroot/milestone/Website/Milestone/Layouts"));
});

// COPY: css
gulp.task("copycss", function() {
  return gulp.src("Assets/Styles/**/*")
    .pipe(gulp.dest("/inetpub/wwwroot/milestone/Website/Milestone/Assets/Styles"));
});

// COPY: js
gulp.task("copyjs", function() {
  return gulp.src("Assets/Scripts/**/*")
    .pipe(gulp.dest("/inetpub/wwwroot/milestone/Website/Milestone/Assets/Scripts"));
});

// COPY: all files
gulp.task("copyfiles", function(cb) {
  gulpSequence(["copyviewfile", "copycss", "copyjs"], cb)  
});