-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
52 lines (47 loc) · 1.41 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
const del = require('del');
const gulp = require('gulp');
const header = require('gulp-header');
const plumber = require('gulp-plumber');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const package = require('./package.json');
var paths = {
input: 'src/*',
output: 'dist/'
};
var banner = {
full:
'/*!\n' +
' * <%= package.name %> - <%= package.description %>\n' +
' * Author: <%= package.author.name %> <<%= package.author.email %>>\n' +
' * Version: v<%= package.version %>\n' +
' * Url: <%= package.repository.url %>\n' +
' * License: <%= package.license %>\n' +
' */\n\n',
min:
'/*!' +
' <%= package.name %> v<%= package.version %>' +
' | <%= package.author.name %> <<%= package.author.email %>>' +
' | <%= package.license %> License' +
' | <%= package.repository.url %>' +
' */\n'
};
function clean(resolve) {
del.sync([paths.output]);
resolve();
}
function buildScripts() {
return gulp.src(paths.input)
.pipe(plumber())
.pipe(header(banner.full, { package: package }))
.pipe(gulp.dest(paths.output))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(header(banner.min, { package: package }))
.pipe(gulp.dest(paths.output))
}
exports.build = gulp.parallel(buildScripts);
exports.watch = function () {
gulp.watch(paths.input, exports.build);
}
exports.default = gulp.series(clean, exports.build);