forked from Kikobeats/uno-zen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
executable file
·105 lines (89 loc) · 3.21 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
'use strict'
# -- Dependencies --------------------------------------------------------------
gulp = require 'gulp'
gulpif = require 'gulp-if'
gutil = require 'gulp-util'
sass = require 'gulp-sass'
concat = require 'gulp-concat'
coffee = require 'gulp-coffee'
header = require 'gulp-header'
uglify = require 'gulp-uglify'
cssnano = require 'gulp-cssnano'
addsrc = require 'gulp-add-src'
changed = require 'gulp-changed'
browserSync = require 'browser-sync'
pkg = require './package.json'
prefix = require 'gulp-autoprefixer'
strip = require 'gulp-strip-css-comments'
reload = browserSync.reload
isProduction = process.env.NODE_ENV is 'production'
# -- Files ---------------------------------------------------------------------
dist =
name : pkg.name
css : 'assets/css'
js : 'assets/js'
src =
sass:
main : 'assets/scss/' + dist.name + '.scss'
files : ['assets/scss/**/**']
js :
common :
main : ['assets/js/src/__init.coffee'
'assets/js/src/main.coffee'
'assets/js/src/cover.coffee']
vendor : ['assets/vendor/fastclick/lib/fastclick.js'
'assets/vendor/instantclick/instantclick.js'
'assets/vendor/pace/pace.min.js'
'assets/vendor/reading-time/build/readingTime.min.js']
post : ['assets/vendor/fitvids/jquery.fitvids.js'
'assets/js/src/prism.js']
css :
main : 'assets/css/' + dist.name + '.css'
vendor : []
banner = [ "/**"
" * <%= pkg.name %> - <%= pkg.description %>"
" * @version <%= pkg.version %>"
" * @link <%= pkg.homepage %>"
" * @author <%= pkg.author.name %> (<%= pkg.author.url %>)"
" * @license <%= pkg.license %>"
" */"
"" ].join("\n")
# -- Tasks ---------------------------------------------------------------------
gulp.task 'js-common', ->
gulp.src src.js.common.main
.pipe changed dist.js
.pipe coffee().on 'error', gutil.log
.pipe addsrc src.js.common.vendor
.pipe concat dist.name + '.common.js'
.pipe gulpif(isProduction, uglify())
.pipe gulpif(isProduction, header banner, pkg: pkg)
.pipe gulp.dest dist.js
return
gulp.task 'js-post', ->
gulp.src src.js.post
.pipe changed dist.js
.pipe concat dist.name + '.post.js'
.pipe gulpif(isProduction, uglify())
.pipe gulpif(isProduction, header banner, pkg: pkg)
.pipe gulp.dest dist.js
return
gulp.task 'css', ->
gulp.src src.css.vendor
.pipe changed dist.css
.pipe addsrc src.sass.main
.pipe sass().on('error', sass.logError)
.pipe concat '' + dist.name + '.css'
.pipe gulpif(isProduction, prefix())
.pipe gulpif(isProduction, strip all: true)
.pipe gulpif(isProduction, cssnano())
.pipe gulpif(isProduction, header banner, pkg: pkg)
.pipe gulp.dest dist.css
return
gulp.task 'server', -> browserSync.init(pkg.browserSync)
gulp.task 'js', ['js-common', 'js-post']
gulp.task 'build', ['css', 'js']
gulp.task 'default', ->
gulp.start ['build', 'server']
gulp.watch src.sass.files, ['css', reload]
gulp.watch src.js.common.main, ['js-common', reload]
gulp.watch src.js.post, ['js-post', reload]