-
Notifications
You must be signed in to change notification settings - Fork 42
/
gulpfile.babel.js
55 lines (50 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
import gulp from 'gulp';
import header from 'gulp-header';
import babel from 'gulp-babel';
import rename from 'gulp-rename';
import size from 'gulp-size';
import uglify from 'gulp-uglify';
import preprocess from 'gulp-preprocess';
import pkg from './package.json';
const banner = `/* ${pkg.name} ${pkg.version} */\n`;
gulp.task('build-browser', () =>
gulp
.src('./index.js')
.pipe(rename('conditioner.js'))
.pipe(
babel({
plugins: ['syntax-dynamic-import', 'transform-es2015-modules-umd'],
presets: [
[
'env',
{
targets: {
browsers: ['last 2 versions']
}
}
]
]
})
)
.pipe(rename(`${pkg.name}.js`))
.pipe(header(banner))
.pipe(gulp.dest('./'))
.pipe(preprocess())
.pipe(uglify())
.pipe(rename(`${pkg.name}.min.js`))
.pipe(header(banner))
.pipe(size({ gzip: true }))
.pipe(gulp.dest('./'))
);
gulp.task('build-esm', () =>
gulp
.src('./index.js')
.pipe(header(banner))
.pipe(rename(`${pkg.name}.esm.js`))
.pipe(size({ gzip: true }))
.pipe(gulp.dest('./'))
);
gulp.task('build', ['build-browser', 'build-esm']);
gulp.task('default', ['build'], () => {
gulp.watch('index.js', ['build']);
});