-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.coffee
110 lines (100 loc) · 2.99 KB
/
gulpfile.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
gulp = require 'gulp'
autoprefixer = require 'gulp-autoprefixer'
cache = require 'gulp-cache'
rimraf = require 'rimraf'
coffee = require 'gulp-coffee'
concat = require 'gulp-concat'
gutil = require 'gulp-util'
help = require 'gulp-task-listing'
imagemin = require 'gulp-imagemin'
jshint = require 'gulp-jshint'
livereload = require 'gulp-livereload'
minifycss = require 'gulp-minify-css'
notify = require 'gulp-notify'
rename = require 'gulp-rename'
sass = require 'gulp-ruby-sass'
server = require('tiny-lr')()
uglify = require 'gulp-uglify'
mocha = require 'gulp-mocha'
# Help
gulp.task 'help', help
# Styles -- Process and minify SASS and stylesheets
gulp.task 'styles', ->
gulp.src 'src/css/**/*.scss'
.pipe sass { style: 'expanded' }
.pipe autoprefixer 'last 2 version'
, 'safari 5'
, 'ie 8'
, 'ie 9'
, 'opera 12.1'
, 'ios 6'
, 'android 4'
.pipe gulp.dest 'public/stylesheets'
.pipe rename { suffix: '.min' }
.pipe minifycss()
.pipe livereload server
.pipe gulp.dest 'public/stylesheets'
.pipe notify { message: 'Styles task complete' }
# Scripts -- Process and minify client-side JavaScript files
gulp.task 'scripts', ->
gulp.src 'src/js/**/*.js'
.pipe jshint '.jshintrc'
.pipe jshint.reporter 'default'
.pipe concat 'main.js'
.pipe gulp.dest 'public/javascripts'
.pipe rename { suffix: '.min' }
.pipe uglify()
.pipe livereload server
.pipe gulp.dest 'public/javascripts'
.pipe notify { message: 'Scripts task complete' }
# Coffee -- Process and minify Coffeescript files
gulp.task 'coffee', ->
gulp.src 'src/js/**/*.coffee'
.pipe coffee { bare: true }
.on 'error', gutil.log
.pipe jshint '.jshintrc'
.pipe jshint.reporter 'default'
.pipe concat 'main.js'
.pipe gulp.dest 'public/javascripts'
.pipe rename { suffix: '.min' }
.pipe uglify()
.pipe livereload server
.pipe gulp.dest 'public/javascripts'
.pipe notify { message: 'Coffee task complete' }
# Images -- Optimize images and static content
gulp.task 'images', ->
gulp.src 'src/images/**/*'
.pipe cache imagemin {
optimizationLevel: 3
, progressive: true
, interlaced: true
}
.pipe livereload server
.pipe gulp.dest 'public/images'
.pipe notify { message: 'Images task complete' }
# Clean -- Purge any files from previous runs
gulp.task 'clean', ->
gulp.src [
'public/stylesheets'
, 'public/javascripts'
, 'public/images'
], { read: false }
.pipe rimraf()
# Default task -- Run the following tasks by default
gulp.task 'default', ->
gulp.start 'styles'
, 'scripts'
, 'coffee'
, 'images'
# Watch -- Listen on port 35729 for resource changes and run the appropriate tasks
gulp.task 'watch', ->
server.listen 35729, (err) ->
return console.log err if err
gulp.watch 'src/js/**/*.js', ['scripts']
gulp.watch 'src/js/**/*.coffee', ['coffee']
gulp.watch 'src/css/**/*.scss', ['styles']
gulp.watch 'src/images/**/*', ['images']
gulp.task 'mocha', ->
gulp.src './test/**/*.js'
.pipe mocha {reporter: 'spec'}
gulp.task 'test', ['mocha']