This repository has been archived by the owner on Jan 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (57 loc) · 1.68 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
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var csso = require('gulp-csso');
var concat = require('gulp-concat');
var babel = require('gulp-babel');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var size = require('gulp-filesize');
var imagemin = require('gulp-imagemin');
var cache = require('gulp-cache');
var reload = browserSync.reload;
gulp.task('sass', function(){
return gulp.src('style/scss/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers : ['last 2 versions'],
cascade : false
}))
.pipe(csso())
.pipe(rename('style.min.css'))
.pipe(gulp.dest('style/'))
.pipe(size());
});
gulp.task('scripts', function(){
return gulp.src('scripts/production/*.js')
.pipe(babel())
.pipe(concat('master.js'))
.pipe(uglify())
.pipe(rename('master.min.js'))
.pipe(gulp.dest('scripts/'))
.pipe(size());
});
gulp.task('imagemin', function(){
return gulp.src('images/original/*.+{png|jpg|jpeg|gif|svg}')
.pipe(cache(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}]
})))
.pipe(gulp.dest('images/optimized/'))
.pipe(size());
});
gulp.task('browserSync', function(){
browserSync.init({
server: {
baseDir: './'
}
});
});
gulp.task('watch', function() {
gulp.watch('*.html').on('change', reload);
gulp.watch('style/scss/*.scss', ['sass']).on('change', reload);
gulp.watch('scripts/production/*.js', ['scripts']).on('change', reload);
gulp.watch('images/original/*', ['imagemin']).on('change', reload);
});
gulp.task('default', ['browserSync', 'sass', 'scripts', 'watch']);