-
-
Notifications
You must be signed in to change notification settings - Fork 651
/
gulpfile.js
68 lines (58 loc) · 1.96 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const babel = require('gulp-babel');
const gulp = require('gulp');
const rename = require('gulp-rename');
const source = gulp.src('./src/raty.js');
const uglifyJS = require('gulp-uglify');
gulp.task('amd', async () => {
source
.pipe(babel({ plugins: ['@babel/plugin-transform-modules-amd'] }))
.pipe(uglifyJS())
.pipe(rename('raty.amd.min.js'))
.pipe(gulp.dest('./build/', { overwrite: true }));
});
gulp.task('umd', async () => {
source
.pipe(babel({ plugins: ['@babel/plugin-transform-modules-umd'] }))
.pipe(uglifyJS())
.pipe(rename('raty.umd.min.js'))
.pipe(gulp.dest('./build/', { overwrite: true }));
});
gulp.task('commonjs', async () => {
source
.pipe(babel({ plugins: ['@babel/plugin-transform-modules-commonjs'] }))
.pipe(uglifyJS())
.pipe(rename('raty.commonjs.min.js'))
.pipe(gulp.dest('./build/', { overwrite: true }));
});
gulp.task('systemjs', async () => {
source
.pipe(babel({ plugins: ['@babel/plugin-transform-modules-systemjs'] }))
.pipe(uglifyJS())
.pipe(rename('raty.systemjs.min.js'))
.pipe(gulp.dest('./build/', { overwrite: true }));
});
gulp.task('es6', async () => {
source
.pipe(babel())
.pipe(uglifyJS())
.pipe(rename('raty.module.min.js'))
.pipe(gulp.dest('./build/', { overwrite: true }));
});
gulp.task('es5', async () => {
source
.pipe(babel({ plugins: ['babel-plugin-remove-import-export'] }))
.pipe(uglifyJS())
.pipe(rename('raty.min.js'))
.pipe(gulp.dest('./build/', { overwrite: true }));
});
gulp.task('es5-test', async () => {
source
.pipe(babel({ plugins: ['babel-plugin-remove-import-export'] }))
.pipe(rename('raty.js'))
.pipe(gulp.dest('./build/', { overwrite: true }));
});
const tasks = gulp.parallel(['amd', 'umd', 'commonjs', 'systemjs', 'es6', 'es5', 'es5-test']);
gulp.task('build', tasks);
gulp.task('watch', async () => {
gulp.watch(['src/*.js', '!build/*.js'], { awaitWriteFinish: true, ignoreInitial: false }, tasks);
});