-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
84 lines (67 loc) · 2.09 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
# GULP-FILE --------------------------------------------------------------------
gulp = require 'gulp'
gutil = require 'gulp-util'
sass = require 'gulp-sass'
browserSync = require 'browser-sync'
browserify = require 'gulp-browserify'
coffeelint = require 'gulp-coffeelint'
rename = require 'gulp-rename'
uglify = require 'gulp-uglify'
rimraf = require 'gulp-rimraf'
runSequence = require 'run-sequence'
# CONFIG -----------------------------------------------------------------------
isRelease = gutil.env.type is 'release'
sources =
sass: 'sass/**/*.scss'
html: 'index.html'
img: 'img/**/*.png'
coffee: 'src/**/*.coffee'
destinations =
css: 'dist/css'
html: 'dist/'
img: 'dist/img'
js: 'dist/js'
# TASKS ------------------------------------------------------------------------
gulp.task 'browser-sync', ->
browserSync.init [
'dist/*.html'
'dist/**/*.js'
'dist/**/*.css'
],
server:
baseDir: './dist'
gulp.task 'style', ->
gulp.src(sources.sass)
.pipe(sass(outputStyle: 'compressed', errLogToConsole: true))
.pipe(rename('app.min.css'))
.pipe(gulp.dest(destinations.css))
gulp.task 'html', ->
gulp.src(sources.html)
.pipe(gulp.dest(destinations.html))
gulp.task 'img', ->
gulp.src(sources.img)
.pipe(gulp.dest(destinations.img))
gulp.task 'lint', ->
gulp.src(sources.coffee)
.pipe(coffeelint())
.pipe(coffeelint.reporter())
gulp.task 'src', ->
gulp.src(sources.coffee, read: false)
.pipe(browserify
transform: ['coffeeify']
extensions: ['.coffee']
insertGlobals: true
debug: not isRelease)
.pipe(rename('app.min.js'))
.pipe(gulp.dest(destinations.js))
gulp.task 'watch', ->
gulp.watch sources.sass, ['style']
gulp.watch sources.coffee, ['lint', 'src', 'html']
gulp.watch sources.html, ['html']
gulp.watch sources.img, ['img']
gulp.task 'clean', ->
gulp.src(['dist/'], read: false).pipe(rimraf())
gulp.task 'build', ->
runSequence 'clean', ['style', 'lint', 'src', 'html', 'img']
gulp.task 'build:watch', ['build', 'browser-sync', 'watch']
gulp.task 'default', ['build']