-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
85 lines (75 loc) · 2.57 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
/**
* Created by Rusak Oleg on 02.02.2016.
*/
'use strict';
const fs = require('fs');
const runSequence = require('run-sequence');
const gulp = require('gulp');
const gutil = require('gulp-util');
const gulpJsdoc2md = require('gulp-jsdoc-to-markdown');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const stylus = require('gulp-stylus');
const jade = require('gulp-jade');
gulp.task('docs', function () {
return gulp.src(['app/**/*.js'])
.pipe(concat('README.md'))
.pipe(gulpJsdoc2md({
template: fs.readFileSync('./jsdoc2md/readme.hbs', 'utf8')
}))
.on('error', function (err) {
gutil.log(gutil.colors.red('jsdoc2md failed'), err.message)
})
.pipe(gulp.dest('./'))
});
gulp.task('public', (callback) => {
runSequence(['babel', 'stylus', 'jade'], ['compress'], 'example', callback);
});
gulp.task('example', function (callback) {
gulp.src('node_modules/javascript-auto-complete/auto-complete.*')
.pipe(gulp.dest('public/example/javascript-auto-complete'))
.on('end', function() {
gulp.src('public/tags-input/*')
.pipe(gulp.dest('public/example/tags-input'))
.on('end', function() {
callback();
});
});
});
gulp.task('babel', () => {
gulp.src(['app/tags-input/tags.js'])
.pipe(babel())
.pipe(gulp.dest('public/tags-input'));
gulp.src(['app/example/service.js'])
.pipe(babel())
.pipe(gulp.dest('public/example'));
}
);
gulp.task('compress', function() {
return gulp.src(['public/tags-input/tags.js', 'public/example/service.js'], {base: './'})
.pipe(uglify())
.pipe(rename(function (path) {
path.extname = ".min.js";
}))
.pipe(gulp.dest("./"));
});
gulp.task('stylus', function (callback) {
return gulp.src('app/tags-input/*.styl')
.pipe(stylus())
.pipe(gulp.dest('public/tags-input'))
.on('end', function() {
gulp.src('app/example/*.styl')
.pipe(stylus())
.pipe(gulp.dest('public/example'))
});
});
gulp.task('jade', function (callback) {
return gulp.src('app/example/*.jade')
.pipe(jade({
pretty: false
}))
.pipe(gulp.dest('public/example'));
});
gulp.task('default', ['docs', 'public']);