This repository has been archived by the owner on Jan 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
170 lines (152 loc) · 3.85 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
166
167
168
169
170
gulp = require 'gulp'
project = 'chat-distract'
dev = yes
libraries = [
'react'
'lodash'
]
gulp.task 'folder', ->
filetree = require 'make-filetree'
filetree.make '.',
source:
'main.coffee': ''
'main.css': ''
'index.cirru': ''
'README.md': ''
build: {}
gulp.task 'watch', ->
plumber = require 'gulp-plumber'
coffee = require 'gulp-coffee'
watch = require 'gulp-watch'
html = require 'gulp-cirru-html'
transform = require 'vinyl-transform'
browserify = require 'browserify'
rename = require 'gulp-rename'
reloader = require 'gulp-reloader'
reloader.listen()
watch glob: 'source/**/*.cirru', emitOnGlob: no, (files) ->
gulp
.src 'source/index.cirru'
.pipe plumber()
.pipe html(data: {dev: yes})
.pipe gulp.dest('./')
.pipe reloader(project)
watch glob: 'source/**/*.coffee', emitOnGlob: no, (files) ->
files
.pipe plumber()
.pipe (coffee bare: yes)
.pipe (gulp.dest 'build/js/')
.pipe rename('main.js')
.pipe transform (filename) ->
b = browserify filename, debug: yes
b.external library for library in libraries
b.bundle()
.pipe gulp.dest('build/')
.pipe reloader(project)
return files
gulp.task 'js', ->
browserify = require 'browserify'
source = require 'vinyl-source-stream'
b = browserify debug: dev
b.add './build/js/main'
b.external library for library in libraries
b.bundle()
.pipe source('main.js')
.pipe gulp.dest('build/')
gulp.task 'coffee', ->
coffee = require 'gulp-coffee'
gulp
.src 'source/**/*.coffee', base: 'source/'
.pipe (coffee bare: yes)
.pipe (gulp.dest 'build/js/')
gulp.task 'html', ->
html = require 'gulp-cirru-html'
gulp
.src 'source/index.cirru'
.pipe html(data: {dev: dev})
.pipe gulp.dest('.')
gulp.task 'jsmin', ->
source = require 'vinyl-source-stream'
uglify = require 'gulp-uglify'
buffer = require 'vinyl-buffer'
browserify = require 'browserify'
b = browserify debug: no
b.add './build/js/main'
b.external library for library in libraries
b.bundle()
.pipe source('main.min.js')
.pipe buffer()
.pipe uglify()
.pipe gulp.dest('build/')
gulp.task 'vendor', ->
source = require 'vinyl-source-stream'
uglify = require 'gulp-uglify'
buffer = require 'vinyl-buffer'
browserify = require 'browserify'
b = browserify debug: no
b.require library for library in libraries
jsbuffer = b.bundle()
.pipe source('vendor.min.js')
.pipe buffer()
if dev
jsbuffer
.pipe gulp.dest('build/')
else
jsbuffer
.pipe uglify()
.pipe gulp.dest('build/')
gulp.task 'prefixer', ->
prefixer = require 'gulp-autoprefixer'
gulp
.src 'source/**/*.css', base: 'source/'
.pipe prefixer()
.pipe gulp.dest('build/css/')
gulp.task 'cssmin', ->
rename = require 'gulp-rename'
cssmin = require 'gulp-cssmin'
gulp
.src 'build/css/main.css'
.pipe cssmin(root: 'build/css')
.pipe rename(suffix: '.min')
.pipe gulp.dest('build/')
gulp.task 'clean', (cb) ->
del = require 'del'
del ['build/'], cb
gulp.task 'start', ->
sequence = require 'run-sequence'
sequence 'clean', 'vendor', 'dev'
gulp.task 'dev', ->
sequence = require 'run-sequence'
sequence ['html', 'coffee'], 'js'
gulp.task 'build', ->
dev = no
sequence = require 'run-sequence'
sequence 'clean',
['coffee', 'html'], ['jsmin', 'vendor'],
'prefixer', 'cssmin'
gulp.task 'rsync', ->
rsync = require('rsyncwrapper').rsync
rsync
ssh: yes
src: '.'
recursive: true
args: ['--verbose']
dest: "tiye:~/repo/#{project}"
deleteAll: yes
exclude: [
'node_modules/'
'README.md'
'data/'
'build/js/'
'build/css/'
'*.json'
'.gitignore'
'.npmignore'
'gulpfile.coffee'
]
, (error, stdout, stderr, cmd) ->
if error? then throw error
if stderr?
console.error stderr
else
console.log cmd