-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
106 lines (93 loc) · 1.92 KB
/
gulpfile.babel.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
100
101
102
103
104
105
106
/*------------------------------------*\
GULPFILE
\*------------------------------------*/
import gulp from 'gulp';
import del from 'del';
import gulpLoadPlugins from 'gulp-load-plugins';
import runSequence from 'run-sequence';
import pkg from './package.json';
const $ = gulpLoadPlugins();
/**
* Config
*/
const pluginName = 'dropit';
const config = {
src: `./src/${pluginName}.js`,
dist: `./dist/`
}
/**
* Banner
*/
var banner = [
'/*!\n' +
' * <%= package.name %>\n' +
' * <%= package.description %>\n' +
' * <%= package.homepage %>\n' +
' * @author <%= package.author %>\n' +
' * @version <%= package.version %>\n' +
' * Copyright ' + new Date().getFullYear() + '. <%= package.license %> licensed.\n' +
' */',
'\n'
].join('');
/**
* Clean task
*/
gulp.task('clean', cb => del([ './dist/*' ], {
read: false,
dot: true,
force: true
}, cb));
/**
* Beautify task
*/
gulp.task('beautify', () => {
gulp.src([config.src])
.pipe($.plumber())
.pipe($.eslint())
.pipe($.uglify({
mangle: false,
compress: false,
output: {
beautify: true,
indent_level: 2
}
}))
.pipe($.header(banner, {
package: pkg
}))
.pipe(gulp.dest(config.dist))
.pipe($.size({title: 'beautify'}));
});
/**
* Minfify task
*/
gulp.task('minify', () => {
gulp.src([config.src])
.pipe($.plumber())
.pipe($.eslint())
.pipe($.uglify())
.pipe($.header(banner, {
package: pkg
}))
.pipe($.rename(`${pluginName}.min.js`))
.pipe(gulp.dest(config.dist))
.pipe($.size({title: 'minify'}));
});
/**
* Watch task
*/
gulp.task('watch', () => {
gulp.watch(config.src, ['beautify', 'minify']);
});
/**
* Default task
*/
gulp.task('default', ['clean'], cb => {
runSequence('beautify', 'minify', 'watch', cb);
});
/**
* Build task
*/
gulp.task('build', ['clean'], cb => {
runSequence('beautify', 'minify', cb);
});