Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Gulpfile for PhoneGap App on Ripple using Browserify
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');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment