-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.coffee
60 lines (50 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
gulp = require 'gulp'
gutil = require 'gulp-util'
clean = require 'gulp-clean'
mocha = require 'gulp-mocha'
cache = require 'gulp-cached'
coffee = require 'gulp-coffee'
webpack = require 'webpack-stream'
coffeelint = require 'gulp-coffeelint'
Renderer = require('birch-doc').Renderer
webpackConfig = require './webpack.config'
gulp.task 'clean', ->
cache.caches = {}
gulp.src(['.coffee/', 'lib/', 'doc/api/', 'min/']).pipe(clean())
gulp.task 'test', ->
gulp.src(['test/**/*-spec.coffee'], read: false)
.pipe(mocha(reporter: 'nyan'))
gulp.task 'javascript', ->
gulp.src('src/**/*.js')
.pipe(cache('javascript'))
.pipe(gulp.dest('lib/'))
gulp.task 'coffeescript', ->
gulp.src('./src/**/*.coffee')
.pipe(cache('coffeescript'))
.pipe(coffeelint())
.pipe(coffeelint.reporter())
.pipe(coffee(bare: true).on('error', gutil.log))
.pipe(gulp.dest('lib/'))
gulp.task 'doc', ->
Renderer.renderModules(['.'], 'doc/api/', layout: 'class')
gulp.task 'webpack', ['javascript', 'coffeescript'], ->
config = Object.create(webpackConfig)
config.output.path = null
gulp.src('lib/index.js')
.pipe(webpack(config))
.pipe(gulp.dest('min/'))
gulp.task 'webpack:watch', ['javascript', 'coffeescript'], ->
config = Object.create(webpackConfig)
config.watch = true
config.output.path = null
config.plugins = [] # remove uglify
gulp.src('lib/index.js')
.pipe(webpack(config))
.pipe(gulp.dest('min/'))
gulp.task 'prepublish', ['clean', 'test', 'doc'], ->
gulp.start('webpack')
gulp.task 'watch', ['clean', 'test', 'doc'], ->
gulp.watch('src/**/*', ['javascript', 'coffeescript', 'test', 'doc'])
gulp.watch('test/**/*', ['test'])
gulp.start('webpack:watch')
gulp.task 'default', ['watch'], ->