-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.coffee
110 lines (89 loc) · 2.4 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
#
# gulpfile.coffee
#
sources =
bower : './bower.json'
jade : './src/jade/**/*.jade'
scss : './src/scss/**/*.scss'
dist : './dist/'
autoprefixer = require 'gulp-autoprefixer'
browserify = require 'browserify'
debowerify = require 'debowerify'
concat = require 'gulp-concat'
cssmin = require 'gulp-cssmin'
filter = require 'gulp-filter'
gulp = require 'gulp'
jade = require 'gulp-jade'
less = require 'gulp-less'
mainBowerFiles = require 'gulp-main-bower-files'
scss = require 'gulp-sass'
source = require 'vinyl-source-stream'
uglify = require 'gulp-uglify'
webserver = require 'gulp-webserver'
#
# task
#
# default
gulp.task 'default', ['build']
gulp.task 'build', [
'build:watch',
'build:lib',
'build:css',
'build:jade',
'build:js',
'build:webserver'
]
# watch
gulp.task 'build:watch', ->
gulp.watch sources.bower, ['build:lib']
gulp.watch sources.jade, ['build:jade']
gulp.watch sources.js, ['build:js']
gulp.watch sources.scss, ['build:css']
# bower
gulp.task 'build:lib', ->
jsFilter = filter '**/*.js'
cssFilter = filter '**/*.css', {restore: true}
lessFilter = filter '**/*.less'
gulp.src sources.bower
.pipe mainBowerFiles()
.pipe jsFilter
.pipe concat 'lib.js'
.pipe uglify { preserveComments: 'some' }
.pipe gulp.dest sources.dist + 'lib/'
gulp.src sources.bower
.pipe mainBowerFiles()
.pipe cssFilter
.pipe gulp.dest './src/lib/'
.pipe cssFilter.restore
.pipe lessFilter
.pipe less()
.pipe gulp.dest './src/lib/'
gulp.src './src/lib/**/*.css'
.pipe concat 'lib.css'
.pipe cssmin()
.pipe gulp.dest sources.dist + 'lib/'
# html
gulp.task 'build:jade', ->
gulp.src sources.jade
.pipe jade { pretty: true }
.pipe gulp.dest sources.dist
# css
gulp.task 'build:css', ->
gulp.src sources.scss
.pipe scss()
.pipe autoprefixer()
.pipe concat 'style.css'
.pipe cssmin()
.pipe gulp.dest sources.dist + 'css/'
# js
gulp.task 'build:js', ->
browserify
entries: ['./src/js/main.jsx', './src/js/main.js']
transform: ['babelify', 'debowerify']
.bundle()
.pipe source 'bundle.js'
.pipe gulp.dest sources.dist + 'js/'
# web server
gulp.task 'build:webserver', ->
gulp.src sources.dist
.pipe webserver { host: '127.0.0.1', livereload: true }