-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathgulpfile.js
74 lines (65 loc) · 1.71 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
69
70
71
72
73
74
const gulp = require('gulp');
const rollup = require('rollup');
const ts = require('rollup-plugin-ts');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const cleanCSS = require('gulp-clean-css');
const output = {
dir: 'dist',
format: 'umd',
name: 'Seatchart',
};
const input = 'src/seatchart.ts';
const plugins = [ts()];
gulp.task('watch', function () {
const watcher = rollup.watch({
input,
output,
plugins,
watch: ['src'],
});
console.log('\n' + '\x1b[32m' + 'Watching files...' + '\x1b[0m', '\n');
watcher.on('event', (event) => {
if (event.code === 'BUNDLE_START') {
console.log(
'\x1b[36m' + 'File changed' + '\x1b[0m' + ', bundling',
'\x1b[35m' + event.input + '\x1b[0m'
);
} else if (event.code === 'BUNDLE_END') {
console.log(
'\x1b[36m' + 'Project bundled' + '\x1b[0m',
'in',
event.duration,
'ms to',
'\x1b[35m' + 'dist/seatchart.js' + '\x1b[0m' + '\n'
);
} else if (event.code === 'ERROR') {
console.log(event.error + '\n');
} else if (event.code === 'FATAL') {
console.log(event.error + '\n');
}
});
return watcher;
});
gulp.task('javascript', async () => {
await rollup
.rollup({
input,
plugins,
})
.then((bundle) => bundle.write(output));
return gulp
.src('dist/seatchart.js')
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist'));
});
gulp.task('style', () => {
return gulp
.src('src/seatchart.css')
.pipe(gulp.dest('dist'))
.pipe(cleanCSS())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist'));
});
gulp.task('build', gulp.parallel('javascript', 'style'));