-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.coffee
83 lines (63 loc) · 2.12 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
gulp = require 'gulp'
coffee = require 'gulp-coffee'
clean = require 'gulp-clean'
es = require 'event-stream' #Used for merging sources
livereload = require 'gulp-livereload'
nodemon = require 'gulp-nodemon'
paths =
coffee_server: ['src/**/*.coffee', '!src/public/**/*.coffee']
coffee_client: ['src/public/**/*.coffee']
views: ['src/views/**/*.jade']
build: './build'
vendor_src: ['bower_components/bootstrap/dist/**/*.*']
vendorjs_src: ['bower_components/jquery/dist/*.js']
server = livereload()
#default task - build project
gulp.task 'default', ['build']
gulp.task 'build', ['coffee', 'views', 'vendor']
gulp.task 'dev', ['build', 'watch','liveupdate']
#update server side scripts
gulp.task 'coffee_server', ->
pipe_coffee paths.coffee_server, paths.build, bare: true
#update client side scripts
gulp.task 'coffee_client', ->
pipe_coffee paths.coffee_client, paths.build + '/public'
gulp.task 'coffee', ['coffee_server','coffee_client']
#update server side view
gulp.task 'views', ->
gulp.src paths.views
.pipe gulp.dest paths.build+'/views'
#update the client vendor scripts and styles. Ex: bootstrap, jquery, etc.
gulp.task 'vendor', (cb)->
es.merge(
gulp.src(paths.vendor_src)
.pipe gulp.dest paths.build+'/public/lib'
,
gulp.src paths.vendorjs_src
.pipe gulp.dest paths.build+'/public/lib/js'
)
#watch all folders and build the projects as file changes is made.
gulp.task 'watch', ->
gulp.watch paths.coffee_server, ['coffee_server']
gulp.watch paths.coffee_client, ['coffee_client']
gulp.watch paths.views, ['views']
#clean the build folder.
gulp.task 'clean', ->
gulp.src(paths.build+"/", read: false)
.pipe(clean())
gulp.task 'liveupdate', ->
nodemon
script: './build/app.js',
watch:'src',
ext: 'coffee',
ignore:['./build/public/**','./build/views/**'],
delay: 2
gulp.watch([paths.build+'/public/**', paths.build+'/views/**'])
.on 'change', (file)->
console.log('client in folder changed '+file.path)
server.changed(file.path)
#helper functions
pipe_coffee = (source, dest, options) ->
gulp.src source
.pipe coffee(options)
.pipe gulp.dest dest