Skip to content

Instantly share code, notes, and snippets.

View ro31337's full-sized avatar

Roman Pushkin ro31337

View GitHub Profile
$ gulp server
<body>
Hello, world!
</body>
<body>
Hello, world!
var watch = require('gulp-watch');
// ...
gulp.task('watch', function() {
// rebuild when jsx, js, html change, in src directory, including subdirectories
watch('./src/**/*.{jsx,js,html}', function() {
gulp.start('build');
});
});
gulp.task('server', ['build'], function() {
gulp
.src('./dist') // everything from ./dist directory
.pipe(server({ // pipe to server object
livereload: true, // reload when files are changed
open: true // and open the browser
}));
});
$ npm install gulp-watch --save-dev
[08:50:41] Finished 'build' after 28 ms
[08:50:41] Starting 'server'...
$ gulp server
[06:50:41] Using gulpfile ~/work/boilerplate/gulpfile.js
[06:50:41] Starting 'build'...
[06:50:41] Starting 'clean'...
[06:50:41] Finished 'clean' after 18 ms
[06:50:41] Starting 'copy-html'...
[06:50:41] Starting 'browserify'...
[06:50:41] Finished 'browserify' after 9.41 μs
[06:50:41] Finished 'copy-html' after 8.17 ms
[06:50:41] Finished 'build' after 28 ms
var gulp = require('gulp');
var server = require('gulp-server-livereload');
var clean = require('gulp-rimraf');
var sequence = require('run-sequence');
gulp.task('build', function(callback) {
sequence('clean', ['copy-html', 'browserify'], callback);
});
// Clean dist folder
gulp.task('server', ['build'], function() {
// ...