-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
81 lines (71 loc) · 1.86 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
// Prerequisites
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
cleanCss = require('gulp-clean-css'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
plumber = require('gulp-plumber'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require('gulp-uglify'),
pump = require('pump'),
dirSync = require('gulp-file-sync');
var config = require('./gulpconfig.json');
var onError = function (err) {
notify.onError({
title: 'Gulp',
subtitle: 'Failure!',
message: 'Error: <%= error.message %>',
sound: 'Beep'
})(err);
this.emit('end');
}
// Build methods
function buildStyles(finished) {
pump([
gulp.src(config.source.vendor.styles.concat(config.source.styles)),
plumber({
errorHandler: onError
}),
sourcemaps.init(),
concat('main.min.css'),
sass(),
cleanCss(),
autoprefixer({
browsers: ['last 3 versions']
}),
sourcemaps.write('.'),
gulp.dest(config.dest.styles),
notify({
'title': 'Gulp',
'message': 'Stylesheets were generated',
onLast: true
})
], finished);
}
function buildScripts(finished) {
pump([
gulp.src(config.source.vendor.scripts.concat(config.source.scripts)),
plumber({
errorHandler: onError
}),
sourcemaps.init(),
concat('main.min.js'),
uglify(),
sourcemaps.write('.'),
gulp.dest(config.dest.scripts),
notify({
'title': 'Gulp',
'message': 'Script files were generated',
onLast: true
})
], finished);
}
function watchForChanges() {
gulp.watch(config.source.styles, buildStyles);
gulp.watch(config.source.scripts, buildScripts);
}
// Tasks
exports.build = gulp.parallel(buildScripts, buildStyles);
exports.watch = gulp.series(exports.build, watchForChanges);
exports.default = exports.watch;