-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
62 lines (52 loc) · 1.17 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
'use strict';
import gulp from 'gulp';
import uglify from 'gulp-uglify';
import rename from 'gulp-rename';
import clean from 'gulp-clean';
import insert from 'gulp-insert';
import pkg from './package.json';
const dirs = {
src: 'lib',
dest: 'dist'
};
const paths = {
lib: `${dirs.src}/**/*.js`,
dist: `${dirs.dest}/**/*`
};
const year = new Date().getFullYear();
const banner = `/**
* ${pkg.name} - ${pkg.description}
* Version v${pkg.version} - ${pkg.homepage}
* Copyright (c) ${year} ${pkg.author.name} - ${pkg.license} license
*/
`;
const prefs = {
uglify: {
output: {
ascii_only: true,
max_line_len: 128000
},
compress: {
negate_iife: false
}
},
rename: {
suffix: '.min',
}
};
gulp.task('clean', () => {
return gulp.src(paths.dist, { read: false })
.pipe(clean());
});
gulp.task('copy', ['clean'], () => {
return gulp.src(paths.lib)
.pipe(gulp.dest(dirs.dest));
});
gulp.task('minify', ['clean'], () => {
return gulp.src(paths.lib)
.pipe(uglify(prefs.uglify))
.pipe(insert.prepend(banner))
.pipe(rename(prefs.rename))
.pipe(gulp.dest(dirs.dest));
});
gulp.task('default', ['clean', 'copy', 'minify']);