-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (58 loc) · 1.98 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
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var gulpif = require('gulp-if');
var notify = require("gulp-notify");
var gulpignore = require('gulp-if');
var sourcemaps = require('gulp-sourcemaps');
var plumber = require('gulp-plumber');
var uglifycss = require('gulp-uglifycss');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var imageminJpegRecompress = require('imagemin-jpeg-recompress');
var reportError = function (error) {
notify({
title: "There's an error",
message: 'Check the console for more details.'
}).write(error);
console.log(error.toString());
this.emit('end');
}
gulp.task('sass', function () {
return gulp.src(['src/sass/**/*.scss', "!src/sass/**/_*.scss"])
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass({
errLogToConsole: true,
//outputStyle: 'compressed',
outputStyle: 'compact',
// outputStyle: 'nested',
// outputStyle: 'expanded',
precision: 10
}).on('error', reportError))
.pipe(sourcemaps.write())
.pipe(uglifycss())
.pipe(gulp.dest('css'));
});
gulp.task('img', function () {
return gulp.src('src/images/**/*')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant(), imageminJpegRecompress({loops: 3, min: 80})]
}))
.pipe(gulp.dest('images'));
});
gulp.task('js', function () {
return gulp.src('src/js/**/*.js')
.pipe(uglify())
.pipe(gulp.dest('js'));
});
gulp.task('watch', function() {
gulp.watch('src/sass/**/*.scss', ['sass']);
gulp.watch('src/js/**/*.js', ['js']);
gulp.watch('src/images/**/*', ['img']);
});
gulp.task('default',['sass','js','img']);