Last active
September 14, 2015 14:10
-
-
Save konstantindenerz/51179cad088b4e9b9252 to your computer and use it in GitHub Desktop.
Config example for: Gulp + Livereload + Nodemon + DNX (ASP.NET)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var gulp = require("gulp"), | |
rimraf = require("rimraf"), | |
concat = require("gulp-concat"), | |
cssmin = require("gulp-cssmin"), | |
uglify = require("gulp-uglify"), | |
project = require("./project.json"), | |
livereload = require('gulp-livereload'), | |
nodemon = require('nodemon'); | |
var paths = { | |
webroot: "./" + project.webroot + "/" | |
}; | |
paths.js = paths.webroot + "js/**/*.js"; | |
paths.minJs = paths.webroot + "js/**/*.min.js"; | |
paths.css = paths.webroot + "css/**/*.css"; | |
paths.minCss = paths.webroot + "css/**/*.min.css"; | |
paths.concatJsDest = paths.webroot + "js/site.min.js"; | |
paths.concatCssDest = paths.webroot + "css/site.min.css"; | |
paths.views = './Views/**/*'; | |
paths.cs = './Controllers/**/*'; | |
gulp.task("clean:js", function(cb) { | |
rimraf(paths.concatJsDest, cb); | |
}); | |
gulp.task("clean:css", function(cb) { | |
rimraf(paths.concatCssDest, cb); | |
}); | |
gulp.task("min:js", function() { | |
gulp.src([paths.js, "!" + paths.minJs], { | |
base: "." | |
}) | |
.pipe(concat(paths.concatJsDest)) | |
.pipe(uglify()) | |
.pipe(gulp.dest(".")) | |
.pipe(livereload()); | |
}); | |
gulp.task("min:css", function() { | |
gulp.src([paths.css, "!" + paths.minCss]) | |
.pipe(concat(paths.concatCssDest)) | |
.pipe(cssmin()) | |
.pipe(gulp.dest(".")) | |
.pipe(livereload()); | |
}); | |
gulp.task("watch", function () { | |
gulp.watch(paths.views, function () { | |
livereload.reload(); | |
}); | |
gulp.watch(paths.js, ["scripts"]); | |
gulp.watch(paths.css, ["styles"]); | |
}); | |
// Run the web server and restart on any changes | |
gulp.task('daemon', function () { | |
livereload.listen() | |
nodemon({ | |
watch: "controllers", | |
ext: "cs", | |
exec: 'dnx web', | |
stdout: false | |
}).on('readable', function () { | |
this.stdout.on('data', function (chunk) { | |
livereload.reload(); | |
process.stdout.write(chunk); | |
}) | |
}) | |
}); | |
gulp.task("scripts", ["clean:js", "min:js"]); | |
gulp.task("styles", ["clean:css", "min:css"]); | |
gulp.task("default", ["scripts", "styles"]); | |
gulp.task("serve", ["scripts", "styles", "watch", "daemon"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment