-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
102 lines (83 loc) · 2.68 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
gulp = require 'gulp'
browserify = require 'browserify'
stringify = require 'stringify'
coffee = require 'gulp-coffee'
coffeeify = require 'coffeeify'
vueify = require 'vueify'
source = require 'vinyl-source-stream'
mocha = require 'gulp-mocha'
gutil = require 'gulp-util'
clean = require 'gulp-clean'
plumber = require 'gulp-plumber'
uglify = require 'gulp-uglifyjs'
concat = require 'gulp-concat'
open = require 'gulp-open'
path = require 'path'
webserver = require 'gulp-webserver'
mochaPhantomJS = require 'gulp-mocha-phantomjs'
exposify = require 'exposify'
config = require './package.json'
project_name = config.name;
target_file = project_name + '.js';
dest = './public/js/';
host = '0.0.0.0'
port = 8888
gulp.task 'default', ['watch']
gulp.task 'webserver', ['build'], ()->
gulp.src 'public'
.pipe webserver
host: host
livereload: true,
port: port,
filter: (filename)->
filename.match(/public/)
gulp.task 'watch', ['webserver'], ()->
gulp.src ['./index.coffee']
.pipe open
uri: "http://#{host}:#{port}/"
gulp.watch ['index.*', 'lib/**/*', "!**/.#*", "!**/#*", "!**/*~"], ['build']
exposify.config =
jquery: '$'
gulp.task 'build', ()->
browserify(['./index.coffee'])
.exclude('./node_modules/jquery/dist/jquery.js')
.transform(coffeeify)
.transform(exposify)
.transform(stringify(['.html']))
.transform(vueify)
.require('./index.coffee', {expose: project_name})
.require('vue')
.bundle()
.on 'error', (err)->
console.error err.message
@emit 'end'
.pipe(plumber())
.pipe(source(target_file))
.pipe(gulp.dest(dest))
gulp.task 'uglify', ['build'], ()->
gulp.src path.join(dest, target_file)
.pipe uglify()
.pipe gulp.dest(dest)
gulp.task 'unit-test', ()->
gulp.src ['./test/**/**_test.js', '!./test/client/**'], { read: false }
.pipe(mocha({ reporter: 'list' }))
.on('error', gutil.log);
gulp.task 'compile-client-test', ['build', 'clean-work'], ()->
gulp.src ['./test/client/**_test.coffee']
.pipe coffee({bare: true}).on('error', gutil.log)
.pipe gulp.dest('./work/')
gulp.task 'copy-client-test', ['compile-client-test'], ()->
gulp.src ['./test/client/**_test.js', './test/client/runner.html']
.pipe gulp.dest('./work/')
gulp.task 'build-client-test', ['copy-client-test'], ()->
gulp.src ['./work/**_test.js', '!./work/client_test_all.js']
.pipe concat('client_test_all.js')
.pipe gulp.dest('./work/')
gulp.task 'client-test', ['build-client-test'], ()->
gulp.src('./work/runner.html').pipe(mochaPhantomJS());
gulp.task 'test', ['unit-test', 'client-test']
gulp.task 'clean-work', ()->
gulp.src('./work/').pipe(clean());
gulp.task 'clean', ['clean-work'], ()->
gulp.src path.join(dest, target_file)
.pipe clean()