forked from yogstation13/demo-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
59 lines (50 loc) · 1.37 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
const gulp = require('gulp');
const less = require('gulp-less');
const concat = require('gulp-concat');
const cleanCSS = require('gulp-clean-css');
const uglify = require('gulp-uglify-es').default;
const del = require('del');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const browserify = require('browserify');
const watchify = require('watchify');
const bundler = browserify({ entries: './index.js' });
gulp.task('clean', () =>
del('./dist', { force: true })
);
gulp.task('js', () =>
bundler.bundle()
.pipe(source('script.min.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('./dist'))
);
gulp.task('css', () =>
gulp.src('./style/**/*.less')
.pipe(less())
.pipe(cleanCSS())
.pipe(concat('style.min.css'))
.pipe(gulp.dest('./dist')),
);
gulp.task('chat_css', () =>
gulp.src('./style/**/*.css')
.pipe(less())
.pipe(cleanCSS())
.pipe(concat('style.chat.css'))
.pipe(gulp.dest('./dist')),
);
gulp.task('watch', () => {
bundler.plugin(watchify);
gulp.series('js')();
bundler.on('update', gulp.series('js'));
gulp.watch(['./style/**/*.less'], gulp.series('css'));
});
gulp.task('copyStatic', () =>
gulp.src('./static/**').pipe(gulp.dest('./dist'))
);
gulp.task('default',
gulp.series('clean',
gulp.parallel('copyStatic', 'js', 'css', 'chat_css')
)
);
gulp.task('dev', gulp.series('css', 'chat_css', 'watch'));