-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
71 lines (60 loc) · 1.77 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
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Gulp dependencies
*/
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const sass = require('gulp-sass');
const cleanCSS = require('gulp-clean-css');
const autoprefixer = require('gulp-autoprefixer');
const babel = require('gulp-babel');
const minify = require('gulp-minify');
const imagemin = require('gulp-imagemin');
const browserSync = require('browser-sync').create();
/*
* Configuration
*/
const config = {
source: './src',
output: './build',
};
gulp.task('scss', () =>
gulp.src(config.source + '/scss/*.scss')
.pipe(plumber())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']}))
.pipe(cleanCSS())
.pipe(gulp.dest(config.output + '/css'))
.pipe(browserSync.stream())
);
gulp.task('js', () =>
gulp.src(config.source + '/js/**/*.js')
.pipe(plumber())
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(minify({
ext:{
src:'-debug.js',
min:'.min.js'
}
}))
.pipe(gulp.dest(config.output + '/js'))
.pipe(browserSync.stream())
);
gulp.task('images', () =>
gulp.src(config.source + '/images/*')
.pipe(imagemin())
.pipe(gulp.dest(config.output + '/images'))
);
gulp.task('serve', ['js', 'scss'], () => {
browserSync.init({
server: {
baseDir: "./"
}
});
gulp.watch(config.source + '/scss/**/*.scss', ['scss']);
gulp.watch(config.source + '/js/**/*.js', ['js']);
gulp.watch("*.html").on('change', browserSync.reload);
});
gulp.task('build', ['scss', 'js', 'images']);
gulp.task('default', ['build', 'serve']);