Skip to content

Instantly share code, notes, and snippets.

@motleydev
Created July 20, 2014 14:42
Show Gist options
  • Save motleydev/a93e3aa6879191c6aef4 to your computer and use it in GitHub Desktop.
Save motleydev/a93e3aa6879191c6aef4 to your computer and use it in GitHub Desktop.

Revisions

  1. motleydev created this gist Jul 20, 2014.
    95 changes: 95 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,95 @@
    var gulp = require('gulp'),
    watch = require('gulp-watch'),
    browserSync = require('browser-sync'),
    rubySass = require('gulp-ruby-sass'),
    jade = require('gulp-jade'),
    data = require('gulp-data'),
    browserify = require('gulp-browserify');

    // Javascripts

    gulp.task('scripts', function() {
    gulp.src('./app/scripts/app.js')
    .pipe(browserify({
    insertGlobals : true,
    debug : !gulp.env.production
    }))
    .pipe(gulp.dest('./build/scripts/'))
    });

    // Styles

    gulp.task('styles', function(){
    gulp.src(['./app/styles/*'])
    .pipe(rubySass({
    sourcemap: true,
    sourcemapPath: '../../app/scss',
    lineNumbers:true
    }))
    .pipe(gulp.dest('./build/styles'))
    })

    // Images

    gulp.task('images', function() {
    gulp.src('./app/images/*')
    .pipe(gulp.dest('./build/images/'))
    });

    // Templates

    gulp.task('templates', function() {
    gulp.src('./app/pages/*.jade')
    .pipe(jade())
    .pipe(gulp.dest('./build/'))
    });

    // Rerun the tasks when something happens

    gulp.task('watch', function() {

    // Watch .scss files
    gulp.watch('./app/scripts/*', ['scripts']);

    // Watch .js files
    gulp.watch('./app/styles/*', ['styles']);

    // Watch image files
    gulp.watch('./app/images/*', ['images']);

    gulp.watch('./app/pages/*', ['templates']);
    });


    // Serve the files & Sync the Browsers

    gulp.task('browser-sync', function() {
    browserSync({
    server: {
    baseDir: "./build/"
    }
    });
    });

    // Arbit reload Task
    gulp.task('bs-reload', function () {
    browserSync.reload();
    });

    // Reload The server
    gulp.task('reload',['watch'], function() {
    gulp.watch('./build/**/*', ['bs-reload']);
    });


    gulp.task('default', [
    'scripts',
    'styles',
    'images',
    'templates', // Soon depricated
    'browser-sync',
    'reload'
    ]
    );

    module.exports = gulp;