-
Notifications
You must be signed in to change notification settings - Fork 61
/
gulpfile.js
89 lines (81 loc) · 2.24 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefix = require('gulp-autoprefixer'),
jsHint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imageMin = require('gulp-imagemin'),
cache = require('gulp-cache'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename'),
del = require('del'),
browserSync = require('browser-sync').create();
gulp.task('html', function() {
return gulp
.src('*.html')
.pipe(gulp.dest('dist'));
});
gulp.task('styles', function() {
return gulp
.src('assets/css/main.sass')
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}
}))
.pipe(sass({outputStyle: 'expanded'}))
.pipe(autoprefix())
.pipe(gulp.dest('dist/assets/css'))
.pipe(rename({suffix: '.min'}))
.pipe(sass({outputStyle: 'compressed'}))
.pipe(gulp.dest('dist/assets/css'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('scripts', function() {
return gulp
.src('assets/js/functions.js')
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}
}))
.pipe(jsHint())
.pipe(jsHint.reporter('default'))
.pipe(gulp.dest('dist/assets/js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('dist/assets/js'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('images', function() {
return gulp
.src('assets/img/*')
.pipe(cache(imageMin({ optimizationLevel: 5, progressive: true, interlaced: true })))
.pipe(gulp.dest('dist/assets/img'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('icons', function() {
return gulp
.src('assets/css/1-tools/fonts/*')
.pipe(gulp.dest('dist/assets/css/fonts'));
});
gulp.task('serve', function() {
browserSync.init({
notify: false,
server: {
baseDir: 'dist/'
}
});
});
gulp.task('clean', function() {
return del(['dist/assets/**']);
});
gulp.task('default', ['html', 'styles', 'scripts', 'images', 'icons'], function() {
gulp.watch('*.html', ['html']).on('change', browserSync.reload);
gulp.watch(['assets/css/**/*.sass',
'assets/css/**/*.scss'],['styles']);
gulp.watch('assets/js/*.js', ['scripts']);
gulp.watch('assets/img/*', ['images']);
gulp.start('serve');
});