-
-
Notifications
You must be signed in to change notification settings - Fork 184
/
gulpfile.js
99 lines (88 loc) · 2.05 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
99
const gulp = require('gulp')
const browserSync = require('browser-sync')
const autoprefixer = require('gulp-autoprefixer')
const uglify = require('gulp-uglify')
const ghPages = require('gulp-gh-pages')
const rename = require('gulp-rename')
const reload = browserSync.reload
const cleanCSS = require('gulp-clean-css')
const header = require('gulp-header')
var pkg = require('./package.json')
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
' ',
''].join('\n')
/* config
---------------------------------------------------- */
/**
* css build
*/
function css () {
return gulp.src('src/tingle.css')
.pipe(autoprefixer({
cascade: false
}))
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest('dist'))
.pipe(reload({ stream: true }))
}
/**
* css build + min
*/
function cssMin () {
return gulp.src('src/tingle.css')
.pipe(autoprefixer({
cascade: false
}))
.pipe(cleanCSS())
.pipe(rename('tingle.min.css'))
.pipe(gulp.dest('dist'))
.pipe(reload({ stream: true }))
}
/**
* js build
*/
function js () {
return gulp.src('src/tingle.js')
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest('dist'))
}
/**
* js build + min
*/
function jsMin () {
return gulp.src('src/tingle.js')
.pipe(uglify({
mangle: true
}))
.pipe(rename('tingle.min.js'))
.pipe(gulp.dest('dist'))
}
/**
* deploy documentation to Github
*/
function deploy () {
return gulp.src('./doc/**/*')
.pipe(ghPages())
}
/**
* copy sources to doc folder
*/
function copy () {
return gulp.src(['dist/**/*'])
.pipe(gulp.dest('doc/tingle'))
}
function watch () {
browserSync.init({
server: './doc'
})
gulp.watch('src/*.js', gulp.series(gulp.parallel(js, jsMin), copy))
gulp.watch('src/*.css', gulp.series(gulp.parallel(css, cssMin), copy))
}
exports.default = gulp.parallel(css, cssMin, js, jsMin)
exports.doc = gulp.series(exports.default, copy, deploy)
exports.watch = watch