-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
56 lines (47 loc) · 1.82 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
const gulp = require('gulp');
const babel = require("gulp-babel");
const watch = require('gulp-watch');
const browserSync = require('browser-sync').create();
const environments = require('gulp-environments');
const uglifycss = require('gulp-uglifycss');
const terser = require('gulp-terser');
const postcss = require('gulp-postcss');
const purgecss = require('gulp-purgecss');
const production = environments.production;
gulp.task('watch', () => {
browserSync.init({
proxy: 'localhost:8080',
});
gulp.watch(['src/main/resources/**/*.html'], gulp.series('copy-html-and-reload'));
gulp.watch(['src/main/resources/**/*.css'], gulp.series('copy-css-and-reload'));
gulp.watch(['src/main/resources/**/*.svg'], gulp.series('copy-svg-and-reload'));
gulp.watch(['src/main/resources/**/*.js'], gulp.series('copy-js-and-reload'));
});
gulp.task('copy-html', () =>
gulp.src(['src/main/resources/**/*.html']).pipe(gulp.dest('target/classes/'))
);
gulp.task('copy-css', () =>
gulp.src(['src/main/resources/**/*.css'])
.pipe(postcss())
.pipe(production(uglifycss()))
.pipe(gulp.dest('target/classes/'))
);
gulp.task('copy-js', () =>
gulp.src(['src/main/resources/**/*.js'])
.pipe(babel())
.pipe(production(terser()))
.pipe(gulp.dest('target/classes/'))
);
gulp.task('copy-svg', () =>
gulp.src(['src/main/resources/**/*.svg'])
.pipe(gulp.dest('target/classes/')));
gulp.task('copy-svg-and-reload', gulp.series('copy-svg', reload));
gulp.task('copy-html-and-reload', gulp.series('copy-html', reload));
gulp.task('copy-css-and-reload', gulp.series('copy-css', reload));
gulp.task('copy-js-and-reload', gulp.series('copy-js', reload));
gulp.task('build', gulp.series('copy-html', 'copy-svg', 'copy-css', 'copy-js'));
gulp.task('default', gulp.series('watch'));
function reload(done) {
browserSync.reload();
done();
}