-
Notifications
You must be signed in to change notification settings - Fork 106
/
gulpfile.js
97 lines (84 loc) · 2.4 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
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var browserify = require('browserify');
var transform = require('vinyl-transform');
var markJSON = require('markit-json');
var docUtil = require('amazeui-doc-util');
var browserSync = require('browser-sync');
var del = require('del');
var runSequence = require('run-sequence');
var reload = browserSync.reload;
gulp.task('clean', function(cb) {
del('dist', cb);
});
gulp.task('copy', function() {
return gulp.src('js/**/*.js')
.pipe(gulp.dest('dist/js'));
});
gulp.task('docs', function(){
return gulp.src(['README.md', 'docs/*.md'])
.pipe(markJSON(docUtil.markedOptions))
.pipe(docUtil.applyTemplate(null, {
pluginTitle: 'Amaze UI Datetime Picker',
pluginDesc: '使用 Amaze UI 样式风格的 jQuery Datetime Picker 插件。',
buttons: 'amazeui/datetimepicker',
head: '<link rel="stylesheet" href="../css/amazeui.datetimepicker.css"/>'
}))
.pipe($.rename(function(file) {
file.basename = file.basename.toLowerCase();
if (file.basename === 'readme') {
file.basename = 'index';
}
file.extname = '.html';
}))
.pipe(gulp.dest(function(file) {
if (file.relative === 'index.html') {
return 'dist'
}
return 'dist/docs';
}));
});
gulp.task('less', function() {
return gulp.src('less/amazeui.datetimepicker.less')
.pipe($.less())
.pipe($.autoprefixer({browsers: docUtil.autoprefixerBrowsers}))
.pipe($.csso())
.pipe(gulp.dest('./dist/css'))
.pipe(gulp.dest('./css'));
});
gulp.task('bundle', function() {
var bundler = transform(function(filename) {
var b = browserify({
entries: filename,
basedir: './'
});
return b.bundle();
});
gulp.src('test/main.js')
.pipe(bundler)
.pipe($.rename({
basename: 'bundle'
}))
.pipe(gulp.dest('test'))
});
// Watch Files For Changes & Reload
gulp.task('serve', ['default'], function () {
browserSync({
notify: false,
server: 'dist',
logPrefix: 'AMP'
});
gulp.watch('dist/**/*', reload);
});
gulp.task('deploy', ['default'], function() {
return gulp.src('dist/**/*')
.pipe($.ghPages());
});
gulp.task('watch', function() {
gulp.watch(['README.md', 'docs/*.md'], ['docs']);
gulp.watch('less/*.less', ['less']);
});
gulp.task('default', function(cb) {
runSequence('clean', ['copy', 'less', 'docs', 'watch'], cb);
});