-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
59 lines (52 loc) · 1.5 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 { series, parallel } = require('gulp');
const browserSync = require('browser-sync').create();
const sass = require('gulp-sass');
const minifyCSS = require('gulp-csso');
const minifyImg = require('gulp-imagemin');
//const minifyJS = require('gulp-uglify');
const concat = require('gulp-concat');
const autoprefixer = require('gulp-autoprefixer');
function css() {
return gulp.src('src/scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(minifyCSS())
.pipe(autoprefixer())
.pipe(concat('style.min.css'))
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.stream());
}
function html() {
return gulp.src('src/**/*.html')
.pipe(gulp.dest('dist'))
.pipe(browserSync.stream());
}
function js() {
return gulp.src('src/js/**/*.js')
// .pipe(concat('script.min.js'))
.pipe(gulp.dest('dist/js'))
.pipe(browserSync.stream());
}
function img() {
return gulp.src('src/img/**/*')
.pipe(minifyImg())
.pipe(gulp.dest('dist/img'))
.pipe(browserSync.stream());
}
function watch() {
browserSync.init({
server: {
baseDir: 'dist'
}
});
gulp.watch('src/scss/**/*.scss', css);
gulp.watch('src/**/*.html', html);
gulp.watch('src/js/**/*.js', js);
gulp.watch('src/img/**/*', img);
}
exports.html = html;
exports.css = css;
exports.js = js;
exports.img = img;
exports.watch = watch;
exports.default = series(watch, html, css, js, img);