Created
July 6, 2016 04:02
-
-
Save openainext/259545f609e6a6bbab7fa8adc04247c8 to your computer and use it in GitHub Desktop.
Gulp + nodemon + ejs + less + browserSync livereload
This file contains hidden or 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
var gulp = require('gulp'), | |
less = require('gulp-less'), | |
path = require('path'), | |
minifyCSS = require('gulp-minify-css'), | |
browserSync = require('browser-sync').create(), | |
nodemon = require('gulp-nodemon'); | |
gulp.task('less', function () { | |
return gulp.src('./public/stylesheets/less/main.less') | |
.pipe(less()) | |
.pipe(minifyCSS()) | |
.pipe(gulp.dest('./public/stylesheets/css')); | |
}); | |
gulp.task('watch', function () { | |
gulp.watch('./public/stylesheets/less/**/*.less', ['less']); | |
gulp.watch("./views/**/*.ejs").on('change', browserSync.reload); | |
}); | |
gulp.task('browser-sync', ['nodemon'], function() { | |
browserSync.init(null, { | |
proxy: "http://localhost:3000", | |
files: ["public/**/*.*"], | |
browser: "google chrome", | |
port: 7000, | |
}); | |
}); | |
gulp.task('nodemon', function (cb) { | |
var started = false; | |
return nodemon({ | |
script: './bin/www' | |
}).on('start', function () { | |
if (!started) { | |
cb(); | |
started = true; | |
} | |
}); | |
}); | |
gulp.task('default', ['less', 'watch','browser-sync']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment