-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
163 lines (139 loc) · 3.63 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
gulp = require 'gulp'
gutil = require 'gulp-util'
project = 'Quamolit/todolisting'
dev = yes
prefix = '/Quamolit/todolisting/dist/'
libraries = [
'shortid'
]
gulp.task 'folder', (cb) ->
filetree = require 'make-filetree'
filetree.make '.',
'index.cirru': ''
src:
'main.coffee': ''
'main.css': ''
lib: {}
'README.md': ''
build: {}
cb()
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()
gulp
.src 'index.cirru'
.pipe watch()
.pipe plumber()
.pipe html(data: {dev: yes})
.pipe gulp.dest('./')
.pipe reloader(project)
gulp
.src 'src/**/*.coffee', base: 'src'
.pipe watch()
.pipe plumber()
.pipe (coffee bare: yes)
.pipe (gulp.dest 'lib/')
.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)
gulp.task 'coffee', ->
coffee = require 'gulp-coffee'
gulp
.src 'src/**/*.coffee', base: 'src/'
.pipe (coffee bare: yes)
.pipe (gulp.dest 'lib/')
gulp.task 'html', ->
html = require 'gulp-cirru-html'
gulp
.src 'index.cirru'
.pipe html(data: {dev: dev})
.pipe gulp.dest('.')
gulp.task 'browserify', ->
browserify = require 'browserify'
source = require 'vinyl-source-stream'
buffer = require 'vinyl-buffer'
uglify = require 'gulp-uglify'
b = browserify debug: dev
b.add './lib/main'
b.external library for library in libraries
jsStream = b.bundle()
.pipe source('main.js')
.pipe (if dev then gutil.noop() else buffer())
.pipe (if dev then gutil.noop() else 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
b.bundle()
.pipe source('vendor.js')
.pipe buffer()
.pipe (if dev then gutil.noop() else uglify())
.pipe gulp.dest('build/')
gulp.task 'prefixer', ->
prefixer = require 'gulp-autoprefixer'
gulp
.src 'src/**/*.css', base: 'src/'
.pipe prefixer()
.pipe gulp.dest('lib/')
gulp.task 'cssmin', ->
cssmin = require 'gulp-cssmin'
gulp
.src 'lib/main.css'
.pipe cssmin(root: 'lib')
.pipe gulp.dest('build/')
gulp.task 'clean', (cb) ->
del = require 'del'
del ['lib/', 'build/', 'dist/'], cb
gulp.task 'dist', (cb) ->
rev = require 'pages-rev'
rev.run
base: "#{__dirname}/"
dest: "#{__dirname}/dist/"
entries: ['index.html']
ignoreDirs: ['node_modules']
prefix: prefix
cb()
gulp.task 'start', (cb) ->
sequence = require 'run-sequence'
sequence 'clean', 'vendor', 'dev', cb
gulp.task 'dev', (cb) ->
sequence = require 'run-sequence'
sequence ['html', 'coffee', 'prefixer'], 'browserify', cb
gulp.task 'build', (cb) ->
dev = no
sequence = require 'run-sequence'
sequence 'start', 'cssmin', cb
gulp.task 'rsync', (cb) ->
rsync = require('rsyncwrapper').rsync
rsync
ssh: yes
src: 'dist/'
recursive: true
args: ['--verbose']
dest: "tiye:~/repo/#{project}"
deleteAll: yes
exclude: []
, (error, stdout, stderr, cmd) ->
if error? then throw error
if stderr? then console.error stderr
else console.log cmd
cb()
gulp.task 'up', (cb) ->
sequence = require 'run-sequence'
prefix = '/todolisting/'
sequence 'dist', 'rsync', cb