-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
122 lines (89 loc) · 3.3 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
gulp = require 'gulp'
argv = require('yargs').argv
gulpif = require 'gulp-if'
jade = require 'gulp-jade'
sass = require 'gulp-sass'
coffee = require 'gulp-coffee'
uglify = require 'gulp-uglify'
cssmin = require 'gulp-cssmin'
rename = require 'gulp-rename'
concat = require 'gulp-concat'
imageResize = require 'gulp-image-resize'
livereload = require 'gulp-livereload'
watch = require 'gulp-watch'
gutil = require 'gulp-util'
mainBowerFiles = require 'main-bower-files'
rootdir = if argv.production then 'prod' else 'dev'
#--------- Initialization Tasks ---------------------------
# Copy bower files to the build directory.
gulp.task 'init:bower', ->
gulp.src(mainBowerFiles('**/*.js'))
.pipe(concat('vendor.js'))
.pipe(gulpif(argv.production, uglify()))
.pipe(gulpif(argv.production, rename(suffix: '.min')))
.pipe(gulp.dest("build/#{rootdir}/js"))
gulp.src(mainBowerFiles(['**/Roboto*.ttf', '**/Roboto*.woff*']))
.pipe(gulp.dest("build/#{rootdir}/font/roboto"))
gulp.src(mainBowerFiles('**/fontawesome-webfont.*'))
.pipe(gulp.dest("build/#{rootdir}/font/font-awesome"))
gulp.src(mainBowerFiles('**/Material-Design-Icons.*'))
.pipe(gulp.dest("build/#{rootdir}/font/material-design-icons"))
# Copy additional resources to the build directory.
gulp.task 'init:img', ->
gulp.src('assets/img/*')
.pipe(imageResize(
width: 1920
upscale: false
))
.pipe(gulp.dest("build/#{rootdir}/img"))
# Combined initialization tasks.
gulp.task 'init', ['init:bower', 'init:img']
#--------- Build Tasks ------------------------------------
# Build site html file from jade templates.
gulp.task 'build:jade', ->
src = gulp.src(['src/*.jade', '!src/layout.jade', '!src/mixins.jade'])
if argv.production
src.pipe(jade())
.pipe(gulp.dest("build/#{rootdir}"))
else
src.pipe(jade(
pretty: true
locals:
development: true
))
.pipe(gulp.dest("build/#{rootdir}"))
.pipe(livereload())
# Build site javascript from coffeescript files.
gulp.task 'build:coffee', ->
src = gulp.src('src/site.coffee')
.pipe(coffee(bare: true).on('error', gutil.log))
if argv.production
src.pipe(uglify())
.pipe(rename(suffix: '.min'))
.pipe(gulp.dest("build/#{rootdir}/js"))
else
src.pipe(gulp.dest("build/#{rootdir}/js"))
.pipe(livereload())
# Build site css file from SASS files.
gulp.task 'build:scss', ->
src = gulp.src('src/styles/*.scss')
.pipe(sass())
if argv.production
src.pipe(cssmin())
.pipe(rename(suffix: '.min'))
.pipe(gulp.dest("build/#{rootdir}/css"))
else
src.pipe(gulp.dest("build/#{rootdir}/css"))
.pipe(livereload())
# Combined build tasks.
gulp.task 'build', ['build:jade', 'build:coffee', 'build:scss']
#--------- Watch and Default Tasks ------------------------
# Setup file watchers.
gulp.task 'watch', ->
gulp.watch 'src/**/*.jade', ['build:jade']
gulp.watch 'src/**/*.coffee', ['build:coffee']
gulp.watch 'src/styles/**/*.scss', ['build:scss']
# Start the live reload server.
livereload.listen()
# Run all tasks by default and begin watching for file changes.
gulp.task 'default', ['init', 'build', 'watch']