-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
53 lines (46 loc) · 1.22 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
const { src, dest, parallel } = require('gulp');
const cssMin = require('gulp-css');
const uglify = require('gulp-uglify');
const concat = require('gulp-concat');
const babel = require('gulp-babel');
const browserSync = require('browser-sync').create();
function html() {
return src('src/index.html')
.pipe(dest('build/'))
}
function css() {
return src('src/css/*.css')
.pipe(concat('main.min.css'))
.pipe(cssMin())
.pipe(dest('build/css'))
}
function js() {
return src('src/js/*.js', { sourcemaps: false })
.pipe(concat('app.min.js'))
.pipe(babel({
presets: ['@babel/preset-env']
}))
.pipe(uglify({ mangle: { toplevel: true } }))
.pipe(dest('build/js', { sourcemaps: false }))
}
function watchSync() {
browserSync.init({
server: {
baseDir: "./build"
}
});
watch("src/css/*.css", css);
watch("src/js/*.js").on("change", () => {
js()
browserSync.reload()
});
watch("src/*.html").on("change", () => {
html()
browserSync.reload()
});
}
exports.js = js;
exports.css = css;
exports.html = html;
exports.watch = watchSync;
exports.default = parallel(html, css, js);