-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
51 lines (43 loc) · 1.14 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
const { src, dest, watch, series } = require('gulp');
const pkg = require('./package.json');
const babel = require('gulp-babel');
const header = require('gulp-header');
const rename = require('gulp-rename');
const terser = require('gulp-terser');
function banner() {
var banner = [
'/**',
' * <%= pkg.name %>',
' * @version v<%= pkg.version %>',
' * @author <%= pkg.author %>',
' * @license <%= pkg.license %>',
' * @see <%= pkg.docs %>',
' */',
''
].join('\n');
return banner;
}
function javascript() {
// console.log('in the js');
return src('src/js/*.js')
.pipe(babel())
.pipe(terser({
compress: true,
keep_fnames: false,
mangle: true
}))
.pipe(rename({ extname: '.min.js' }))
// .pipe(header(banner(), { pkg : pkg }))
.pipe(dest('output/'))
.pipe(rename({ prefix: 'bookmarklet-' }))
.pipe(header('javascript:'))
.pipe(dest('output/'));
}
exports.default = function() {
// You can use a single task
//watch('src/*.css', css);
watch('src/js/*.js', javascript );
// Or a composed task
//watch('src/js/*.js', series(css, javascript));
};
exports.javascript = javascript;