This repository has been archived by the owner on Jan 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.coffee
77 lines (65 loc) · 1.72 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
gulp = require "gulp"
gutil = require "gulp-util"
cache = require "gulp-cached"
changed = require "gulp-changed"
rename = require "gulp-rename"
serve = require "gulp-serve"
stylus = require "gulp-stylus"
babel = require "gulp-babel"
plumber = require "gulp-plumber"
watch = require "gulp-watch"
notify = require "gulp-notify"
runSequence = require "run-sequence"
src =
build: "./src/*.js"
examples: "./examples/**/*.es6"
stylus: "./examples/**/*.styl"
dest =
build: "./dist"
examples: "./examples/"
stylus: "./examples/"
gulp.task "build", ["babel", "stylus"]
gulp.task "default", ["build", "watch", "serve"]
gulp.task "stylus", ->
gulp.src src.stylus
.pipe plumber(
errorHandler: notify.onError(
"Stylus build error: <%= error.name %> <%= error.message %>"
)
)
.pipe cache "stylus"
.pipe stylus()
.pipe rename (path) ->
path.extname = ".css"
.pipe gulp.dest dest.stylus
doBabel = (src, dest, renameCallback = ()->) ->
gulp.src src
.pipe plumber(
errorHandler: notify.onError(
"Babel build error: <%= error.name %> <%= error.message %>"
)
)
.pipe cache "babel"
.pipe changed dest, extension: ".js"
.pipe babel
modules: "amd"
.on "error", (error) ->
@hadError = true
gutil.log(
gutil.colors.red(
"#{error.name}: #{error.message} (#{error.fileName})"
)
)
.pipe rename renameCallback
.pipe gulp.dest dest
gulp.task "babel", ->
doBabel src.build, dest.build
doBabel src.examples, dest.examples, (path) ->
path.extname = ".js"
gulp.task "watch", ["build"], ->
watch [src.build, src.examples], ->
runSequence "babel"
watch [src.stylus], ->
runSequence "stylus"
gutil.log "Watcher started"
gulp.task "serve", serve "./"