Created
March 21, 2014 20:21
-
-
Save bdecarne/9695538 to your computer and use it in GitHub Desktop.
gulp files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var gulp = require('gulp'), | |
| sass = require('gulp-sass'), | |
| browserify = require('gulp-browserify'), | |
| concat = require('gulp-concat'), | |
| embedlr = require('gulp-embedlr'), | |
| livereload = require('gulp-livereload'), | |
| express = require('express'), | |
| livereloadport = 35729, | |
| serverport = 5000; | |
| //We only configure the server here and start it only when running the watch task | |
| var server = express(); | |
| server.use(express.static('./build')); | |
| //Task for sass using libsass through gulp-sass | |
| gulp.task('sass', function(){ | |
| gulp.src('sass/*.scss') | |
| .pipe(sass()) | |
| .pipe(gulp.dest('build')) | |
| .pipe(livereload()); | |
| }); | |
| //Task for processing js with browserify | |
| gulp.task('browserify', function(){ | |
| gulp.src('js/*.js') | |
| .pipe(browserify()) | |
| .pipe(concat('bundle.js')) | |
| .pipe(gulp.dest('build')) | |
| .pipe(livereload()); | |
| }); | |
| //Task for moving html-files to the build-dir | |
| //added as a convenience to make sure this gulpfile works without much modification | |
| gulp.task('html', function(){ | |
| gulp.src('views/*.html') | |
| .pipe(embedlr()) | |
| .pipe(gulp.dest('build')) | |
| .pipe(livereload()); | |
| }); | |
| //Convenience task for running a one-off build | |
| gulp.task('build', function() { | |
| gulp.run('html', 'browserify', 'sass'); | |
| }); | |
| gulp.task('serve', function() { | |
| //Set up your static fileserver, which serves files in the build dir | |
| server.listen(serverport); | |
| }); | |
| gulp.task('watch', function() { | |
| //Add watching on sass-files | |
| gulp.watch('sass/*.scss', function() { | |
| gulp.run('sass'); | |
| }); | |
| //Add watching on js-files | |
| gulp.watch('js/*.js', function() { | |
| gulp.run('browserify'); | |
| }); | |
| //Add watching on html-files | |
| gulp.watch('views/*.html', function () { | |
| gulp.run('html'); | |
| }); | |
| }); | |
| gulp.task('default', function () { | |
| gulp.run('build', 'serve', 'watch'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment