-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.coffee
127 lines (107 loc) · 2.79 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
'use strict'
gulp = require 'gulp'
runs = require 'run-sequence'
$ = require('gulp-load-plugins')()
filename = require('uuid').v4()
browserSync = require 'browser-sync'
reload = browserSync.reload
paths =
src: 'app'
script: 'app/assets/js'
css: 'app/assets/css'
images: 'app/assets/images'
test: 'test'
dist: 'dist'
vendor: 'app/assets/vendor'
# Lint JavaScript
gulp.task 'jshint', ->
gulp.src 'app/assets/js/**/*.js'
.pipe reload stream: true, once: true
.pipe $.fixmyjs
legacy: true
.pipe gulp.dest 'app/assets/js/'
.pipe $.jshint()
.pipe $.jshint.reporter 'jshint-stylish'
.pipe $.if !browserSync.active, $.jshint.reporter 'fail'
gulp.task 'test_coffee', ->
gulp.src paths.test + '/**/*.coffee'
.pipe $.changed paths.test,
extension: '.js'
.pipe $.coffee bare: true
.pipe gulp.dest paths.test
gulp.task 'html', ->
assets = $.useref.assets()
gulp.src paths.src + '/*.html'
.pipe $.replace 'main.min', filename
.pipe assets
# Concatenate And Minify JavaScript
.pipe $.if '*.js', $.uglify()
.pipe $.if '*.css', $.uncss
html: ['app/index.html']
# Concatenate And Minify Styles
.pipe $.if '*.css', $.csso()
.pipe assets.restore()
.pipe $.useref()
.pipe $.if '*.html', $.minifyHtml()
.pipe gulp.dest paths.dist
.pipe $.size title: 'html'
# Clean
gulp.task 'clean', require('del').bind null, [
paths.dist
]
# Images
gulp.task 'images', ->
gulp.src paths.images + '/**/*.{jpg,jpeg,png,gif}'
.pipe $.changed paths.dist + '/assets/images'
.pipe $.imagemin
progressive: true
interlaced: true
.pipe gulp.dest paths.dist + '/assets/images'
.pipe $.size title: 'images'
# testing via mocha tool
gulp.task 'test', ->
gulp.src paths.test + '/**/*.js'
.pipe $.mocha
reporter: 'spec'
# Connect
gulp.task 'connect:app', ->
browserSync
notify: false
server:
baseDir: [paths.src]
# run tasks automatically when files change
gulp.watch paths.test + '/**/*.coffee', ['test_coffee']
gulp.watch paths.src + '/*.html', reload
gulp.watch paths.css + '/**/*.css', reload
gulp.watch paths.images + '/**/*.{jpg,jpeg,png,gif}', reload
gulp.watch paths.script + '/**/*.js', ['jshint', reload]
# Connect
gulp.task 'connect:dist', ->
browserSync
notify: false
server:
baseDir: [paths.dist]
gulp.watch paths.dist + '/**/*', reload
gulp.task 'copy', ->
gulp.src [
paths.src + '/favicon.ico'
paths.src + '/robots.txt']
.pipe gulp.dest paths.dist
# The default task (called when you run `gulp`)
gulp.task 'default', (cb) ->
runs(
'connect:app'
cb)
# Build
gulp.task 'build', (cb) ->
runs([
'jshint'
'images'
'copy']
'html'
cb)
gulp.task 'release', (cb) ->
runs(
['build']
cb)
module.exports = gulp