forked from aluxian/aluxian.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.coffee
89 lines (76 loc) · 2.59 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
fs = require 'fs'
del = require 'del'
ecstatic = require 'ecstatic'
mergeStream = require 'merge-stream'
gulp = require 'gulp'
http = require 'http'
$ = require('gulp-load-plugins')()
port = 8888
live = false
DIST = '../gh-pages'
gulp.task 'live', -> live = true
gulp.task 'purge', (cb) -> del([DIST], cb)
gulp.task 'clean', (cb) -> del([DIST + '/**'], cb)
gulp.task 'jade', ->
gulp.src 'src/index.jade'
.pipe $.jade
pretty: !live
locals: JSON.parse(fs.readFileSync('./src/locals.json'))
.pipe $.if live, $.htmlmin
collapseWhitespace: true
keepClosingSlash: true
.pipe gulp.dest DIST
gulp.task 'assets', ->
img = gulp.src 'src/img/**'
.pipe gulp.dest DIST + '/img'
assets = gulp.src [
'src/favicons/**'
'src/assets/**'
]
.pipe gulp.dest DIST
mergeStream img, assets
gulp.task 'fonts', ->
gulp.src 'src/sass/fonts.sass'
.pipe $.sass
outputStyle: if live then 'compressed' else 'nested'
errLogToConsole: true
indentedSyntax: true
.pipe $.if live, $.cssmin()
.pipe gulp.dest DIST
gulp.task 'sass', ->
gulp.src ['bower_components/normalize-css/normalize.css', 'src/sass/styles.sass']
.pipe $.if /[.]sass$/, $.sass({
outputStyle: if live then 'compressed' else 'nested'
indentedSyntax: true
includePaths: [
'bower_components/bourbon/app/assets/stylesheets/'
'bower_components/neat/app/assets/stylesheets/'
]
}).on 'error', (err) ->
$.sass.logError err
this.emit 'end'
.pipe $.concat 'styles.css'
# .pipe $.if live, $.combineMediaQueries() # crashes build
.pipe $.if live, $.cssmin()
.pipe gulp.dest DIST
gulp.task 'coffee', ->
gulp.src ['bower_components/smooth-scroll/dist/js/smooth-scroll.js', 'src/scripts.coffee']
.pipe $.if /[.]coffee$/, $.coffee({ bare: true }).on('error', $.util.log)
.pipe $.concat 'scripts.js'
.pipe $.if live, $.uglify()
.pipe gulp.dest DIST
gulp.task 'static', ['build'], (next) ->
http.createServer ecstatic { root: DIST, cache: 'no-cache', showDir: true }
.listen port, ->
$.util.log 'Static server listening at ' + $.util.colors.cyan("http://localhost:#{port}/")
next()
gulp.task 'watch', ['static'], ->
gulp.watch './src/sass/*.sass', ['fonts', 'sass']
gulp.watch './src/index.jade', ['jade']
gulp.watch './src/scripts.coffee', ['coffee']
gulp.watch './src/locals.json', ['jade']
gulp.watch './src/img/**', ['assets']
gulp.watch './src/favicons/**', ['assets']
gulp.watch './src/svg/**', ['jade']
gulp.task 'build', ['jade', 'assets', 'fonts', 'sass', 'coffee']
gulp.task 'default', ['watch']