example from milestone.com
/// <binding BeforeBuild='default' Clean='clean' />
/*
This file in the main entry point for defining Gulp tasks and using Gulp plugins.
Click here to learn more. http://go.microsoft.com/fwlink/?LinkId=518007
*/
var gulp = require("gulp");
var util = require("gulp-util");
//var debug = require('gulp-debug');
var sass = require("gulp-sass");
var autoprefixer = require("gulp-autoprefixer");
var sourcemaps = require("gulp-sourcemaps");
var md5 = require("gulp-md5-plus");
var fs = require("fs");
var path = require("path");
var del = require("del");
var preen = require("preen");
var getFolders = function(folderPath) {
return fs.readdirSync(folderPath)
.filter(function(file) {
var filePath = path.join(folderPath, file);
return fs.statSync(filePath).isDirectory() && fs.existsSync(filePath + "/src/js") && !/^Website/.test(file);
});
};
gulp.task("default",
["js", "sass", "images"],
function() {
// place code for your default task here
});
gulp.task("watch",
function() {
var array = ["src/**/*"];
var folders = getFolders("../");
folders.map(function(folder) {
array.push(path.join("../", folder, "/src/js/**/*.js"));
});
gulp.watch(array, ["js", "copydev"]);
});
gulp.task("sass",
["clean"],
function() {
return gulp.src("src/styles/*.scss")
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(sourcemaps.write())
.pipe(autoprefixer({
browsers: ['last 5 versions'],
cascade: false
}))
//.pipe(md5(10, 'Views/Milestone/Project/Layouts/Default.cshtml'))
.pipe(gulp.dest("dist/styles"));
});
gulp.task("js",
["clean", "preen"],
function() {
var array = [path.join("src/js/**/*.js")];
var folders = getFolders("../");
folders.map(function(folder) {
array.push(path.join("../", folder, "/src/js/**/*.js"));
});
return gulp.src(array)
.pipe(gulp.dest("dist/js"));
});
gulp.task("images",
["clean"],
function(cb) {
return gulp.src("src/images/**/*")
.pipe(gulp.dest("dist/images"));
});
gulp.task("preen",
function(cb) {
preen.preen({}, cb);
});
gulp.task("copydev",
["js", "sass", "images"],
function() {
return gulp.src("dist/**/*")
.pipe(gulp.dest("/inetpub/MilestoneDev/Website/dist"));
});
gulp.task("clean",
function() {
return del(["dist/**/*"], { force: true });
});