-
Notifications
You must be signed in to change notification settings - Fork 39
/
gulpfile.coffee
123 lines (92 loc) · 2.55 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
123
gulp = require 'gulp'
# code processing
postcss = require 'gulp-postcss'
stylus = require 'gulp-stylus'
jade = require 'gulp-jade'
rupture = require 'rupture'
# assets
usemin = require 'gulp-usemin'
uglify = require 'gulp-uglify'
browserify = require 'gulp-browserify'
# utils
plumber = require 'gulp-plumber'
watch = require 'gulp-watch'
jadeGlobbing = require 'gulp-jade-globbing'
colors = require 'colors'
notify = require 'gulp-notify'
runSequence = require 'run-sequence'
browserSync = require('browser-sync').create()
processors = [
require('autoprefixer')
browsers: ['> 1%', 'last 5 versions']
]
# --- MARKUP ---
# Jade compilation
gulp.task 'jade', ->
gulp.src ['src/views/*.jade', '!src/views/_*.jade']
.pipe plumber
errorHandler: notify.onError
message: '<%= error.message %>',
title: 'Jade'
.pipe jadeGlobbing()
.pipe jade
pretty: true
.pipe gulp.dest 'dist'
# --- STYLES ---
# Styus compilation
gulp.task 'styles', ->
gulp.src 'src/styles/main.styl'
.pipe plumber
errorHandler: notify.onError
message: '<%= error.message %>',
title: 'Styles'
.pipe stylus
use: [rupture()]
.pipe postcss processors
.pipe gulp.dest 'dist/css'
.pipe browserSync.reload
stream: true
# --- SCRIPTS ---
# Browserify with Bebel transpiling
gulp.task 'scripts', ->
gulp.src 'src/js/app.js', { read: false }
.pipe plumber
errorHandler: notify.onError
message: '<%= error.message %>',
title: 'JS'
.pipe browserify
paths: ['./node_modules', './src/js']
transform: ['babelify']
insertGlobals: true
# debug: true
.pipe gulp.dest 'dist/js'
# Compress js
gulp.task 'compress', ->
gulp.src 'dist/js/app.concat.js'
.pipe uglify
preserveComments: 'license'
.pipe gulp.dest 'dist/js'
# Assets concat
gulp.task 'usemin', ->
gulp.src 'dist/*.html'
.pipe usemin
js: []
css: []
.pipe gulp.dest 'dist'
# --- MISC ---
gulp.task 'serve', ->
browserSync.init
port: 8000
open: false
notify: false
reloadOnRestart: true
ghostMode: false
server:
baseDir: './dist'
# Default task
gulp.task 'default', ->
runSequence 'serve', 'scripts', 'jade', 'styles'
watch ['src/styles/**/*.styl'], -> runSequence 'styles'
watch ['src/views/*.jade', 'src/partials/*.jade'], -> runSequence 'jade'
watch ['src/js/**/*.js'], -> runSequence 'scripts'
watch ['dist/*.html', 'dist/js/**/*.js'], browserSync.reload