-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
99 lines (84 loc) · 2.42 KB
/
gulpfile.js
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
var browserify = require('browserify');
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var streamify = require('gulp-streamify');
var connect = require('gulp-connect');
var source = require('vinyl-source-stream');
var args = require('yargs').argv;
var verb = require("gulp-verb");
var deploy = require("gulp-gh-pages");
var packageJson = require('./package.json');
var name = packageJson.exports || packageJson.name;
var exports = packageJson.exports;
var dependencies = Object.keys(packageJson && packageJson.dependencies || {});
gulp.task('dependencies', function () {
return browserify()
.require(dependencies)
.bundle()
.pipe(source('dependencies.js'))
.pipe(gulp.dest('./tests/'));
});
gulp.task('lib', function () {
return browserify('./index.js')
.external(dependencies)
.bundle({
standalone : name
})
.pipe(source('lib.js'))
.pipe(gulp.dest('./tests/'));
});
gulp.task('standalone', function () {
return browserify('./index.js')
.bundle({
standalone : name
})
.pipe(source(packageJson.name + '.js'))
.pipe(gulp.dest('./'));
});
gulp.task('uglify', function() {
return browserify('./index.js')
.bundle()
.pipe(source(packageJson.name + '.min.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest('./'));
});
gulp.task('connectDev', function () {
connect.server({
root: ['./'],
port: 9001,
livereload: false
});
});
gulp.task('verb-docs', function () {
gulp.src(['docs/README.tmpl.md'])
// dest filename is defined in options,
// otherwise gulp will overwrite .verbrc.md
.pipe(verb({
dest: 'README.md',
type: 'docs',
jsstart : '```js',
jsend : '```'
}))
.pipe(gulp.dest('./'));
});
gulp.task('verb-gh-pages', function () {
gulp.src(['docs/index.tmpl.md'])
// dest filename is defined in options,
// otherwise gulp will overwrite .verbrc.md
.pipe(verb({
dest: 'index.html',
type: 'gh-pages',
jsstart : '<script>',
jsend : '</script>'
}))
.pipe(gulp.dest('./gh-pages'))
.pipe(deploy({remoteUrl : packageJson.repository.url}));
});
//var type = args.type || "build";
gulp.task('default', ['standalone', 'uglify']);
gulp.task('watch', function() {
gulp.watch("./", ['dependencies', 'lib']);
});
gulp.task('test', ['dependencies', 'lib', 'connectDev' , 'watch']);
gulp.task('docs', ['verb-docs']);
gulp.task('gh-pages', ['verb-gh-pages']);