-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
43 lines (39 loc) · 1.04 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
const autoprefixer = require('gulp-autoprefixer');
const babel = require('gulp-babel');
const browserSync = require('browser-sync').create();
const { series, parallel, src, dest, watch } = require('gulp');
const concat = require('gulp-concat');
const sass = require('gulp-sass');
const uglify = require('gulp-uglify');
function js() {
return src('./src/js/**/*.js')
.pipe(
babel({
presets: ['@babel/env'],
})
)
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(dest('./dist/js'));
}
function style() {
return src('./src/scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer())
.pipe(dest('./dist/css'))
.pipe(browserSync.stream());
}
function build() {
browserSync.init({
server: {
baseDir: './',
},
});
watch('./src/scss/**/*.scss', style);
watch('./src/js/**/*.js', js);
watch('./**/*html').on('change', browserSync.reload);
watch('./src/js/**/*.js').on('change', browserSync.reload);
}
exports.watch = build;
exports.js = js;
exports.style = style;