This repository has been archived by the owner on Apr 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.coffee
155 lines (122 loc) · 3.99 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
gulp = require 'gulp'
gutil = require 'gulp-util'
stylus = require 'gulp-stylus'
CSSmin = require 'gulp-minify-css'
browserify = require 'browserify'
watchify = require 'watchify'
concat = require 'gulp-concat'
source = require 'vinyl-source-stream'
streamify = require 'gulp-streamify'
symlink = require 'gulp-sym'
uglify = require 'gulp-uglify'
coffeeify = require 'coffeeify'
ecstatic = require 'ecstatic'
livereload = require 'gulp-livereload'
production = process.env.NODE_ENV is 'production'
paths =
scripts :
watch : './src/*.coffee'
source : './src/main.coffee'
destination : './public/js/'
filename : 'main.js'
styles :
source : './src/styl/main.styl'
watch : './src/styl/*.styl'
destination : './public/css/'
handleError = (err) ->
gutil.log err
gutil.beep()
this.emit 'end'
gulp.task 'scripts', ->
bundle = browserify
entries: [paths.scripts.source]
extensions: ['.coffee']
bundle.transform coffeeify
build = bundle.bundle(debug: not production)
.on 'error', handleError
.pipe source paths.scripts.filename
build.pipe streamify uglify() if production
build
.pipe gulp.dest paths.scripts.destination
gulp.task 'styles', ->
styles = gulp
.src paths.styles.source
.pipe(stylus({set: ['include css']}))
.on 'error', handleError
styles = styles.pipe CSSmin() if production
styles.pipe gulp.dest paths.styles.destination
.pipe livereload()
gulp.task 'build-libs', ->
build = gulp.src [
"./src/coffee-script.min.js"
"./src/js2coffee.min.js"
"./src/codemirror/lib/codemirror.js"
"./src/codemirror/addon/hint/show-hint.js"
"./src/codemirror/addon/hint/javascript-hint.js"
"./src/codemirror/mode/javascript/javascript.js"
"./src/codemirror/mode/coffeescript/coffeescript.js"
"./src/codemirror/mode/css/css.js"
"./src/jshint.js"
"./src/codemirror/addon/selection/active-line.js"
"./src/codemirror/addon/search/searchcursor.js"
"./src/codemirror/addon/search/search.js"
"./src/codemirror/addon/dialog/dialog.js"
"./src/codemirror/addon/edit/matchbrackets.js"
"./src/codemirror/addon/edit/closebrackets.js"
"./src/codemirror/addon/comment/comment.js"
"./src/codemirror/addon/wrap/hardwrap.js"
"./src/codemirror/addon/fold/foldcode.js"
"./src/codemirror/addon/fold/brace-fold.js"
"./src/codemirror/addon/fold/foldgutter.js"
"./src/codemirror/addon/fold/comment-fold.js"
"./src/codemirror/addon/fold/indent-fold.js"
"./src/codemirror/addon/lint/coffeelint.js"
"./src/codemirror/addon/lint/lint.js"
"./src/codemirror/addon/lint/javascript-lint.js"
"./src/codemirror/addon/lint/coffeescript-lint.js"
"./src/codemirror/keymap/sublime.js"
"./src/kd.libs.js"
"./src/kd.js"
]
build.pipe streamify uglify() if production
build
.pipe concat 'coffeepad.js'
.pipe gulp.dest paths.scripts.destination
gulp.task 'server', ->
require 'http'
.createServer ecstatic root: __dirname + '/public'
.listen 1903
gulp.task "watch", ->
livereload.listen()
gulp.watch paths.styles.watch, ['styles']
gulp.watch paths.scripts.watch, ['scripts']
bundle = watchify
entries : [paths.scripts.source]
extensions : ['.coffee']
bundle.transform coffeeify
bundle.on 'update', ->
build = bundle.bundle debug: not production
.on 'error', handleError
.pipe source paths.scripts.filename
build
.pipe gulp.dest paths.scripts.destination
.pipe livereload()
.emit 'update'
gulp.task "create-links", ->
gulp
.src [
'./src/images',
'./src/css',
'./src/chrome',
'./src/index.html'
'./src/manifest.json'
]
.pipe symlink [
'./public/images',
'./public/css',
'./public/chrome',
'./public/index.html'
'./public/manifest.json'
], force: yes
gulp.task "build", ["build-libs", "scripts", "styles", "create-links"]
gulp.task "default", ["build", "watch", "server"]