Skip to content

Instantly share code, notes, and snippets.

@rix501
Created January 31, 2014 20:56
Show Gist options
  • Save rix501/8742957 to your computer and use it in GitHub Desktop.
Save rix501/8742957 to your computer and use it in GitHub Desktop.
Rough gulpfile
http = require('http')
connect = require('connect')
lr = require('tiny-lr')
livereload = lr()
gulp = require('gulp')
using = require('gulp-using')
gutil = require('gulp-util')
compass = require('gulp-compass')
clean = require('gulp-clean')
notify = require('gulp-notify')
coffee = require('gulp-coffee')
coffeelint = require('gulp-coffeelint')
refresh = require('gulp-livereload')
handlebars = require('gulp-handlebars')
react = require('gulp-react')
src = 'www'
build_dir = 'build'
dist_dir = 'dist'
gulp.task 'clean', ->
gulp.src("#{build_dir}/*", read: false)
.pipe(clean())
gulp.task 'copy', ->
gulp.src("#{src}/coffee/**/*.js")
.pipe(gulp.dest("#{build_dir}/js"))
gulp.src("#{src}/img/**/*.{png,jpg,gif,otf}")
.pipe(gulp.dest("#{build_dir}/img"))
gulp.src("#{src}/*.*")
.pipe(gulp.dest("#{build_dir}"))
gulp.task 'react', ->
gulp.src("#{src}/jsx/**/*.jsx")
.pipe(react())
.pipe(gulp.dest("#{build_dir}/jsx"))
.pipe(refresh(livereload))
gulp.task 'handlebars', ->
gulp.src("#{src}/templates/**/*.handlebars")
.pipe(handlebars(
outputType: 'amd'
wrapped: true
))
.pipe(gulp.dest("#{build_dir}/templates/"))
.pipe(refresh(livereload))
gulp.task 'coffee', ->
gulp.src("#{src}/coffee/**/*.coffee")
.pipe(coffeelint())
.pipe(coffee()
.on('error', gutil.log))
.pipe(gulp.dest("#{build_dir}/js"))
.pipe(refresh(livereload))
gulp.task 'compass', ->
gulp.src("#{src}/sass/**/*.{sass,scss}")
.pipe(compass(
sass: "#{src}/sass"
css: "#{build_dir}/css"
image: "#{build_dir}/img"
javascript: "#{build_dir}/js"
))
# .pipe(gulp.dest("#{build_dir}/css"))
# .pipe(refresh(livereload))
gulp.task 'connect-livereload', ->
middleware = [
require('connect-livereload')({ port: 35729 }),
connect.static(build_dir),
connect.directory(build_dir)
]
app = connect.apply(null, middleware)
server = http.createServer(app)
server.listen(8888)
gulp.task 'tinylr', ->
livereload.listen 35729, (err) ->
console.log(err) if (err)
gulp.task 'compile', ['clean'], ->
gulp.start 'copy', 'coffee', 'handlebars', 'react', 'compass'
gulp.task 'server', ['compass', 'copy', 'coffee', 'handlebars', 'react', 'connect-livereload', 'tinylr'], ->
gulp.watch("#{src}/sass/**/*", ['compass'])
gulp.watch("#{src}/coffee/**/*.coffee", ['coffee'])
gulp.watch("#{src}/jsx/**/*.jsx", ['react'])
gulp.watch("#{src}/templates/**/*.handlebars", ['handlebars'])
gulp.task 'default', ['clean'], ->
gulp.start('server')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment