-
Notifications
You must be signed in to change notification settings - Fork 11
/
gulpfile.js
47 lines (41 loc) · 1.33 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
const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
const babel = require('gulp-babel');
const rename = require('gulp-rename');
const concat = require('gulp-concat');
const order = require('gulp-order');
gulp.task('compilejs', gulp.series((done) => {
//create concatenated version
gulp.src('./src/*.js')
.pipe(babel())
.pipe(order([
'**/Websockettest.js'
]))
.pipe(concat('rmbtws.js'))
.pipe(gulp.dest('dist'));
//create minified version
gulp.src('./src/*.js')
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(order([
'**/Websockettest.js'
]))
.pipe(uglify({
preserveComments: 'license'
}))
.pipe(concat('rmbtws.min.js'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'));
//note: we can't do both at once due to problems with
//preserveComments : 'license'; which does not work
//with the concatenated file
done();
}));
gulp.task('watchForChanges', gulp.series((done) => {
gulp.watch('./src/**/*.js', gulp.series('compilejs'));
done();
}));
gulp.task('watch', gulp.series('compilejs', 'watchForChanges'));
gulp.task('build', gulp.series('compilejs'));
gulp.task('default', gulp.series('compilejs'));