Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save openainext/259545f609e6a6bbab7fa8adc04247c8 to your computer and use it in GitHub Desktop.
Save openainext/259545f609e6a6bbab7fa8adc04247c8 to your computer and use it in GitHub Desktop.
Gulp + nodemon + ejs + less + browserSync livereload
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