Skip to content

Instantly share code, notes, and snippets.

@obihann
Created June 21, 2016 16:29
Show Gist options
  • Save obihann/2ee996db32262c33be94c7ea5d640551 to your computer and use it in GitHub Desktop.
Save obihann/2ee996db32262c33be94c7ea5d640551 to your computer and use it in GitHub Desktop.
Gulp script for webkit and browsersync that includes tar/gzip and rsync for bundling and releaseing.
var gulp = require('gulp');
var tar = require('gulp-tar');
var gzip = require('gulp-gzip');
var webpack = require('webpack-stream');
var watch = require('gulp-watch');
var plumber = require('gulp-plumber');
var browserSync = require('browser-sync').create();
var rsync = require('gulp-rsync');
var entry, dest, webkitDevConfig, webkitConfig, devServer;
entry = 'src/jsx/entry.jsx';
dest = 'app/dest/';
webkitDevConfig = './webpack-dev.config.js';
webkitConfig = './webpack.config.js';
devServer = '/Volumes/www/dev/h';
appRoot = 'app/';
gulp.task('browser-sync', function() {
browserSync.init({
server: './app'
});
gulp.watch('src/*.html', ['copy']).on('change', browserSync.reload);
});
gulp.task('webpack-dev', function() {
return gulp.src(entry)
.pipe(plumber())
.pipe(webpack(
require(webkitDevConfig)
))
.pipe(gulp.dest('app/dist/'))
.pipe(browserSync.stream());
});
gulp.task('webpack-prod', function() {
return gulp.src(entry)
.pipe(plumber())
.pipe(webpack(
require(webkitConfig)
))
.pipe(gulp.dest(dest))
.pipe(browserSync.stream());
});
gulp.task('rsync', function() {
gulp.src('app/**')
.pipe(rsync({
destination: devServer,
root: appRoot,
archive: true,
silent: false,
compress: true,
update: true,
progress: true,
}));
});
gulp.task('copy', function() {
gulp.src('src/index.html')
.pipe(gulp.dest('app'));
});
gulp.task('tarball', function() {
gulp.src(appRoot)
.pipe(tar('app.tar'))
.pipe(gzip())
.pipe(gulp.dest('.'));
});
gulp.task('build', ['copy', 'webpack-prod']);
gulp.task('package', ['copy', 'webpack-prod', 'tarball']);
gulp.task('release', ['copy', 'webpack-prod', 'rsync']);
gulp.task('dev', ['copy', 'webpack-dev', 'browser-sync']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment