Skip to content

Instantly share code, notes, and snippets.

@basicallydan
Created February 12, 2014 07:06
Show Gist options
  • Select an option

  • Save basicallydan/8951183 to your computer and use it in GitHub Desktop.

Select an option

Save basicallydan/8951183 to your computer and use it in GitHub Desktop.

Revisions

  1. basicallydan created this gist Feb 12, 2014.
    58 changes: 58 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    var gulp = require('gulp');
    var browserify = require('gulp-browserify');
    var concat = require('gulp-concat');
    var styl = require('gulp-styl');
    var path = require('path');
    var o = require('open');
    var ripple = require('ripple-emulator');
    var webPath = function (p) { return path.join('./www/', p); };

    // Builds the scripts based on a single entry point using browserify
    gulp.task('scripts', function() {
    gulp.src([webPath('js/index.js')])
    .pipe(browserify({
    transform: ['hbsfy'],
    insertGlobals: true
    }))
    .pipe(concat('scripts.min.js'))
    .pipe(gulp.dest(webPath('build')));
    });

    // Concatenates all the CSS files together.
    gulp.task('styles', function() {
    gulp.src([webPath('css/**/*.css')])
    .pipe(styl({
    compress: true
    }))
    .pipe(gulp.dest(webPath('build')));
    });

    // The default task
    gulp.task('default', function() {
    // Watch the JS directory for changes and re-run scripts task when it changes
    gulp.watch(webPath('js/**'), function(evt) {
    gulp.run('scripts');
    });

    // Watch the CSS directory for changes and re-run styles task when it changes
    gulp.watch(webPath('css/**'), function(evt) {
    gulp.run('styles');
    });

    // Run scripts and styles tasks for the first time
    gulp.run('scripts');
    gulp.run('styles');

    var options = {
    keepAlive: false,
    open: true,
    port: 4400
    };

    // Start the ripple server
    ripple.emulate.start(options);

    if (options.open) {
    o('http://localhost:' + options.port + '?enableripple=cordova-3.0.0');
    }
    });