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.

Revisions

  1. Abdullah created this gist Dec 13, 2015.
    43 changes: 43 additions & 0 deletions Gulp + nodemon + ejs + less + browserSync livereload
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    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']);