-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
64 lines (53 loc) · 1.71 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
gulp = require 'gulp'
coffee = require 'gulp-coffee'
uglify = require 'gulp-uglify'
concat = require 'gulp-concat'
sourcemaps = require 'gulp-sourcemaps'
sass = require 'gulp-sass'
del = require 'del'
gulpif = require 'gulp-if'
plumber = require 'gulp-plumber'
env = process.env.ENV or 'dev'
isDev = env is 'dev'
isProd = env is 'prod'
outputDir = 'public'
paths =
scripts: 'coffee_client/**/*.coffee'
styles: 'sass/main.scss'
server: ['*.coffee', '!gulpfile.coffee']
gulp.task 'clean_styles', (cb)->
del outputDir + '/css' , cb
gulp.task 'clean_scripts', (cb)->
del outputDir + '/js' , cb
gulp.task 'scripts', ['clean_scripts'], ->
gulp.src paths.scripts
.pipe plumber()
.pipe gulpif isDev, sourcemaps.init()
.pipe coffee()
.pipe gulpif isProd, uglify()
.pipe concat 'main.js'
.pipe gulpif isDev, sourcemaps.write()
.pipe gulp.dest outputDir + '/js'
gulp.task 'styles', ['clean_styles'], ->
config = {}
config.sourceComments = 'map' if isDev
config.outputStyle = 'compressed' if isProd
gulp.src paths.styles
.pipe plumber (error)->
console.error error.message
this.emit 'end'
.pipe sass config
.pipe gulp.dest outputDir + '/css'
gulp.task 'server', ->
gulp.src paths.server
.pipe plumber()
.pipe gulpif isDev, sourcemaps.init()
.pipe coffee()
.pipe gulpif isDev, sourcemaps.write()
.pipe gulp.dest '.'
gulp.task 'watch', ->
gulp.watch paths.scripts, ['scripts']
gulp.watch paths.styles, ['styles']
gulp.watch paths.server, ['server']
gulp.task 'default', ['scripts','styles','server','watch']
gulp.task 'compile', ['scripts','server']