-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.coffee
165 lines (146 loc) · 5.07 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
gulp = require 'gulp'
sass = require 'gulp-sass'
coffee = require 'gulp-coffee'
concat = require 'gulp-concat'
gutil = require 'gulp-util'
rename = require 'gulp-rename'
clean = require 'gulp-clean'
gulpif = require 'gulp-if'
karma = require('karma').server
preprocess = require 'gulp-preprocess'
# Minification
uglify = require 'gulp-uglify'
minifyHTML = require 'gulp-minify-html'
minifyCSS = require 'gulp-minify-css'
imagemin = require 'gulp-imagemin'
pngcrush = require 'imagemin-pngcrush'
# Angular Helpers
ngAnnotate = require 'gulp-ng-annotate'
htmlify = require 'gulp-angular-htmlify'
del = require 'del'
flatten = require 'gulp-flatten'
size = require 'gulp-size'
livereload = require 'gulp-livereload'
path =
app:
scripts: ["client/app/**/*.{coffee,js}", "client/app/**/*.{coffee,js}"] # All .js and .coffee files, starting with app.coffee or app.js
styles: "client/app/**/*.{scss,sass,css}" # css and scss files
bower: 'client/components'
templates: "client/app/**/*.{html,jade}" # All html, jade, and markdown files used as templates within the app
images: "client/app/**/*.{png,jpg,jpeg,gif,ico}" # All image files
static: "client/app/static/*.*" # Any other static content such as the favicon
lib: "client/lib/**/*"
tasks = {}
gulp.task 'test', (done) ->
karma.start
configFile: __dirname + '/karma.conf.js'
#singleRun: true
, done
gulp.task 'scripts', tasks.scripts = () ->
coffeestream = coffee({bare: true})
coffeestream.on("error", gutil.log)
gulp.src path.app.scripts
.pipe(gulpif(/[.]coffee$/, coffeestream))
.pipe(preprocess())
.pipe(ngAnnotate())
.pipe(concat("app.js"))
.pipe(size())
.pipe(gulp.dest("www/js"))
.pipe(uglify())
.pipe(rename({extname: ".min.js"}))
.pipe(size())
.pipe(gulp.dest "www/js")
# .pipe(livereload())
gulp.task 'scripts:clean', ['clean'], tasks.scripts
gulp.task "styles", tasks.styles = ->
sassstream = sass({
errLogToConsole: true,
sourceComments: 'normal'
sourcemap: false,
unixNewlines: true,
style: 'nested',
debugInfo: false,
quiet: false,
lineNumbers: true,
bundleExec: true
})
sassstream.on("error", gutil.log)
gulp.src path.app.styles
.pipe(gulpif(/[.]sass|scss$/, sassstream))
.pipe(concat 'app.css')
.pipe(size())
.pipe(gulp.dest "www/css")
.pipe(minifyCSS())
.pipe(rename({extname: ".min.css"}))
.pipe(size())
.pipe(gulp.dest "www/css")
# .pipe(livereload())
gulp.task 'styles:clean', ['clean'], tasks.styles
gulp.task 'templates', tasks.templates = ->
gulp.src path.app.templates
.pipe(size())
.pipe(gulp.dest('www'))
# .pipe(livereload())
gulp.task 'templates:clean', ['clean'], tasks.templates
gulp.task 'jquery', tasks.jquery = ->
gulp.src('client/components/jquery/dist/jquery.min.js')
.pipe(size())
.pipe(gulp.dest('www/js'))
gulp.task 'jquery:clean', ['clean'], tasks.jquery
gulp.task 'bowerjs', tasks.bowerjs = ->
gulp.src(
[
'client/components/**/*.min.js',
'!client/components/jquery/dist/jquery.min.js',
'!client/components/angular/**/*.*',
'!client/components/angular-animate/**/*.*',
'!client/components/angular-sanitize/**/*.*',
'!client/components/angular-ui-router/**/*.*',
'!client/components/ionic/**/*.*'
]
)
.pipe(flatten())
.pipe(concat 'vendor.min.js')
.pipe(size())
.pipe(gulp.dest('www/js'))
gulp.task 'bowerjs:clean', ['clean'], tasks.bowerjs
gulp.task 'bowercss', tasks.bowercss = ->
gulp.src(
[
'client/components/**/*.min.css'
'!client/components/angular/**/*.*',
'!client/components/angular-animate/**/*.*',
'!client/components/angular-sanitize/**/*.*',
'!client/components/angular-ui-router/**/*.*',
'!client/components/ionic/**/*.*'
]
)
.pipe(flatten())
.pipe(concat 'vendor.min.css')
.pipe(size())
.pipe(gulp.dest('www/css'))
gulp.task 'bowercss:clean', ['clean'], tasks.bowercss
gulp.task 'assets', tasks.assets = ->
gulp.src(path.app.images)
.pipe(imagemin({optimizationLevel: 5}))
.pipe(size())
.pipe(gulp.dest 'www/assets')
# .pipe(livereload())
gulp.task 'assets:clean', ['clean'], tasks.assets
gulp.task 'lib', tasks.lib = ->
gulp.src(path.app.lib)
.pipe(size())
.pipe(gulp.dest 'www/lib')
gulp.task 'lib:clean', ['clean'], tasks.lib
gulp.task 'watch', () ->
# livereload.listen()
gulp.watch path.app.lib, ['lib']
gulp.watch path.app.scripts, ['scripts']
gulp.watch path.app.styles, ['styles']
gulp.watch path.app.bower, ['bowerjs', 'bowercss']
gulp.watch path.app.templates, ['templates']
gulp.watch path.app.images, ['assets']
gulp.task 'clean', (cb) ->
del(['www/**'], cb)
gulp.task 'default', ['build', 'watch']
gulp.task 'build', ['lib:clean','scripts:clean', 'styles:clean', 'templates:clean', 'jquery:clean', 'bowerjs:clean', 'bowercss:clean', 'assets:clean']