Refactored client-side asset build automation to fix watch triggering.

This commit is contained in:
Daniel Stolt
2015-06-10 16:26:51 +03:00
parent 9fbaed9123
commit c1eff70f4a
2 changed files with 14 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
/// <binding BeforeBuild='build' ProjectOpened='watch' />
/*
* This gulpfile enables building of front-end assets in this project.
* This gulpfile provides an automated build pipeline for client-side assets in this project.
*
* To use this file you will need to:
* - Install Node.js on your machine
@@ -13,9 +13,7 @@
*/
var gulp = require("gulp"),
watch = require("gulp-watch"),
watchLess = require("gulp-watch-less"),
batch = require("gulp-batch"),
newer = require("gulp-newer"),
plumber = require("gulp-plumber"),
sourcemaps = require("gulp-sourcemaps"),
less = require("gulp-less"),
@@ -65,14 +63,15 @@ gulp.task("buildLess", function () {
});
gulp.task("watchLess", function () {
return merge([
lessPipelineFrom(watchLess(srcLessLib, { maxListeners: 64 }), "Styles", "Lib.css"),
lessPipelineFrom(watchLess(srcLessLayoutEditor, { maxListeners: 64 }), "Styles", "LayoutEditor.css")
]);
var watcher = gulp.watch([srcLessLib, srcLessLayoutEditor], ["buildLess"]);
watcher.on("change", function (event) {
console.log("LESS file " + event.path + " was " + event.type + ", running the 'buildLess' task...");
});
});
function lessPipelineFrom(inputStream, outputFolder, outputFile) {
return inputStream
.pipe(newer(outputFolder + "/" + outputFile))
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(less())
@@ -138,15 +137,15 @@ gulp.task("buildJs", function () {
});
gulp.task("watchJs", function () {
return merge([
jsPipelineFrom(watch(srcJsLib)),
jsPipelineFrom(watch(srcJsLayoutEditor)),
jsPipelineFrom(watch(srcJsModels))
]);
var watcher = gulp.watch([srcJsLib, srcJsLayoutEditor, srcJsModels], ["buildJs"]);
watcher.on("change", function (event) {
console.log("JavaScript file " + event.path + " was " + event.type + ", running the 'buildJs' task...");
});
});
function jsPipelineFrom(inputStream, outputFolder, outputFile) {
return inputStream
.pipe(newer(outputFolder + "/" + outputFile))
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(concat(outputFile))

View File

@@ -1,9 +1,7 @@
{
"devDependencies": {
"gulp": "^3.8.11",
"gulp-watch": "^4.2.4",
"gulp-watch-less": "^1.0.1",
"gulp-batch": "^1.0.5",
"gulp-newer": "^0.5.0",
"gulp-plumber": "^1.0.0",
"gulp-sourcemaps": "^1.5.2",
"gulp-less": "^3.0.3",
@@ -12,7 +10,7 @@
"gulp-uglify": "^1.2.0",
"gulp-rename": "^1.2.2",
"gulp-concat": "^2.5.2",
"merge-stream": "^0.1.7"
"del": "^1.1.1"
},
"dependencies": { }
}