This repository has been archived by the owner on Sep 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
83 lines (68 loc) · 1.93 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
clean = require 'gulp-clean'
coffee = require 'gulp-coffee'
coffeelint = require 'gulp-coffeelint'
gulp = require 'gulp'
gutil = require 'gulp-util'
less = require 'gulp-less'
recess = require 'gulp-recess'
runSequence = require 'run-sequence'
uglify = require 'gulp-uglify'
uglifycss = require 'gulp-uglifycss'
dirs =
js: '*/static/**/*.js'
coffee: '*/static/**/*.coffee'
css: '*/static/**/*.css'
less: '*/static/**/*.less'
# Clean old JS
gulp.task 'clean-js', ->
return gulp.src(dirs.js, read: false)
.pipe clean()
# Lint Coffeescript
gulp.task 'lint-coffee', ->
return gulp.src dirs.coffee
.pipe coffeelint()
.pipe coffeelint.reporter('default')
# Convert Coffeescript to JS
gulp.task 'coffee-to-js', ->
return gulp.src dirs.coffee
.pipe coffee(bare: true).on('error', gutil.log)
.pipe gulp.dest('.')
# Minify JS
gulp.task 'minify-js', ->
return gulp.src dirs.js
.pipe uglify()
.pipe gulp.dest('.')
# Clean CSS
gulp.task 'clean-css', ->
return gulp.src(dirs.css, read: false)
.pipe clean()
# Lint Less
gulp.task 'lint-less', ->
return gulp.src(dirs.less)
.pipe recess()
.pipe recess.reporter()
# Compile Less to CSS
gulp.task 'less', ->
return gulp.src(dirs.less)
.pipe less()
.pipe gulp.dest('.')
# Minify CSS
gulp.task 'minify-css', ->
return gulp.src(dirs.css)
.pipe uglifycss()
.pipe gulp.dest('.')
# Build coffee
gulp.task 'build-coffee', ->
return runSequence 'clean-js', 'lint-coffee', 'coffee-to-js', 'minify-js'
# Build css
gulp.task 'build-less', ->
return runSequence 'clean-css', 'lint-less', 'less', 'minify-css'
# Watch Files For Changes
gulp.task 'watch', ->
gulp.watch dirs.coffee, ['build-coffee']
gulp.watch dirs.less, ['build-less']
# Build coffee and css
gulp.task 'build-both', ['build-coffee', 'build-less']
# Build then watch code
gulp.task 'default', ->
return runSequence 'build-both', 'watch'