forked from rikschennink/fitty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
51 lines (46 loc) · 1.16 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
import gulp from 'gulp';
import header from 'gulp-header';
import babel from 'gulp-babel';
import rename from 'gulp-rename';
import uglify from 'gulp-uglify';
import size from 'gulp-size';
const pkg = require('./package.json');
const banner =
`/*
* ${ pkg.name } v${ pkg.version } - ${ pkg.description }
* Copyright (c) ${ new Date().getFullYear() } ${ pkg.author }
*/
`;
gulp.task('build-node', () => {
gulp.src('./src/fitty.js')
.pipe(babel({
plugins: [
'transform-object-rest-spread'
],
presets: ['es2015']
}))
.pipe(header(banner, { pkg }))
.pipe(rename('fitty.module.js'))
.pipe(gulp.dest('./dist'));
});
gulp.task('build-web', () => {
gulp.src('./src/fitty.js')
.pipe(babel({
compact:true,
plugins: [
'add-module-exports',
'transform-object-rest-spread',
'transform-es2015-modules-umd'
],
presets: ['es2015']
}))
.pipe(uglify())
.pipe(size({ gzip:true }))
.pipe(header(banner, { pkg }))
.pipe(rename('fitty.min.js'))
.pipe(gulp.dest('./dist'));
});
gulp.task('build', ['build-web', 'build-node']);
gulp.task('default', ['build'], () => {
gulp.watch('./src/fitty.js', ['build']);
});