-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGulpfile.coffee
101 lines (87 loc) · 2.33 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
gulp = require 'gulp'
connect = require 'gulp-connect'
concat = require 'gulp-concat'
coffee = require 'gulp-coffee'
jade = require 'gulp-pug'
stylus = require 'gulp-stylus'
autoprefixer = require 'gulp-autoprefixer'
rename = require 'gulp-rename'
cleanCSS = require 'gulp-clean-css'
sourcemaps = require 'gulp-sourcemaps'
uglify = require 'gulp-uglify-es'
ngAnnotate = require 'gulp-ng-annotate'
# ignore = require 'gulp-ignore'
# rimraf = require 'gulp-rimraf'
pathJade = 'src/**/*.jade'
pathStylus = 'src/**/*.styl'
pathCoffee = 'src/*.coffee'
dirWatch = 'src/**/**'
dirDist = process.env.BUILD ? 'build'
appJs = [
'src/js/utils.coffee'
'src/js/typeahead.coffee'
'src/js/app.coffee'
]
vendorJs = [
'bower_components/jquery/dist/jquery.min.js'
'bower_components/angular/angular.min.js'
'bower_components/angular-route/angular-route.min.js'
'bower_components/ngstorage/ngStorage.min.js'
'bower_components/angular-cache/dist/angular-cache.min.js'
'bower_components/typeahead.js/dist/typeahead.bundle.min.js'
'bower_components/bootstrap/dist/js/bootstrap.min.js'
'bower_components/js-yaml/dist/js-yaml.min.js'
]
html = ->
gulp
.src pathJade
.pipe jade()
.pipe gulp.dest(dirDist)
copy = ->
gulp
.src 'src/copy/**'
.pipe gulp.dest(dirDist)
rm_css = ->
gulp
.src "#{dirDist}/*.css*"
.pipe rimraf()
css = ->
gulp
.src pathStylus
.pipe sourcemaps.init()
.pipe stylus()
.pipe autoprefixer()
.pipe gulp.dest(dirDist)
.pipe cleanCSS()
.pipe rename(suffix: '.min')
.pipe sourcemaps.write('.')
.pipe gulp.dest(dirDist)
js = ->
gulp
.src appJs
.pipe sourcemaps.init()
.pipe coffee(bare: true)
.pipe ngAnnotate()
.pipe concat('index.js')
.pipe gulp.dest(dirDist)
.pipe uglify.default()
.pipe concat('index.min.js')
.pipe sourcemaps.write('.')
.pipe gulp.dest(dirDist)
.pipe connect.reload()
vendor_min = ->
gulp
.src vendorJs
.pipe concat('vendor.min.js')
.pipe gulp.dest(dirDist)
vendor = ->
gulp
.src vendorJs.map((i) -> i.replace('.min', ''))
.pipe concat('vendor.js')
.pipe gulp.dest(dirDist)
exports.default = gulp.series(html, css, copy, js, vendor, vendor_min)
watch = ->
gulp.watch dirWatch, exports.default
serve = ->
connect.server root: 'build', livereload: true
exports.watch = gulp.parallel(watch, serve)