forked from ciar4n/imagehover.css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (81 loc) · 1.74 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
/**
* Load modules
*/
const gulp = require('gulp');
const cssnano = require('gulp-cssnano');
const notify = require("gulp-notify");
const plumber = require('gulp-plumber');
const rename = require('gulp-rename');
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
/**
* Custom error function for Plumber.
*
* @param err
*/
let onError = function(err) {
notify.onError({
title: "Error",
message: "<%= error %>",
})(err);
this.emit('end');
};
/**
* Plumber options
*
* @type {{errorHandler: onError}}
*/
const plumberOptions = {
errorHandler: onError,
};
/**
* Gulp minify task
*
* Build and minify styles for production/distributed use.
*/
gulp.task('minify', function () {
gulp.src('scss/imagehover.scss')
.pipe(sourcemaps.init())
.pipe(sass({
errLogToConsole: true,
}).on('error', sass.logError))
.pipe(rename('imagehover.min.css'))
.pipe(cssnano({
safe: true,
autoprefixer: false,
convertValues: false,
}))
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest('css'));
});
/**
* Build task
*/
gulp.task('build', function () {
gulp.src('scss/imagehover.scss')
.pipe(plumber(plumberOptions))
.pipe(sourcemaps.init())
.pipe(sass({
indentWidth: 4,
outputStyle: 'expanded',
}))
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest('css'));
});
/**
* Gulp watch task
*/
gulp.task('watch', function () {
// Watch SCSS files for changes
gulp.watch(
['scss/*.scss'],
['build']
);
});
/**
* Default Gulp task
*
* Build then watch SCSS files.
*
*/
gulp.task('default', ['build', 'watch']);