-
Notifications
You must be signed in to change notification settings - Fork 25
/
gulpfile.js
97 lines (84 loc) · 2.31 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
90
91
92
93
94
95
96
97
const gulp = require('gulp');
const fs = require('fs');
const $ = require('gulp-load-plugins')();
const pngquant = require('imagemin-pngquant');
const mergeStream = require('merge-stream');
// Sass tasks
gulp.task('sass', function () {
return gulp.src(['./src/sass/**/*.scss'])
.pipe($.plumber({
errorHandler: $.notify.onError('<%= error.message %>')
}))
.pipe($.sourcemaps.init({loadMaps: true}))
.pipe($.sassGlob())
.pipe($.sass({
errLogToConsole: true,
outputStyle : 'compressed',
includePaths : [
'./src/sass'
]
}))
.pipe($.autoprefixer())
.pipe($.sourcemaps.write('./map'))
.pipe(gulp.dest('./assets/css'));
});
// Minify All
gulp.task('js', function () {
return gulp.src(['./src/js/**/*.js'])
.pipe($.plumber({
errorHandler: $.notify.onError('<%= error.message %>')
}))
.pipe($.sourcemaps.init({
loadMaps: true
}))
.pipe($.uglify())
.pipe($.sourcemaps.write('./map'))
.pipe(gulp.dest('./assets/js/'));
});
// JS Hint
gulp.task('jshint', function () {
return gulp.src(['./src/js/**/*.js'])
.pipe($.jshint('./src/.jshintrc'))
.pipe($.jshint.reporter('jshint-stylish'));
});
// Build libraries
gulp.task('copylib', function () {
return mergeStream(
// Copy LigatureSymbols
gulp.src([
'./src/fonts/**/*'
])
.pipe(gulp.dest('./assets/fonts/')),
// Copy JS Cookie
gulp.src([
'./node_modules/js-cookie/dist/js.cookie.min.js',
'./node_modules/js-cookie/dist/js.cookie.js'
])
.pipe(gulp.dest('./assets/js/'))
);
});
// Image min
gulp.task('imagemin', function () {
return gulp.src('./src/img/**/*')
.pipe($.imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use : [pngquant()]
}))
.pipe(gulp.dest('./assets/img'));
});
// watch
gulp.task('watch', function ( done ) {
// Make SASS
gulp.watch('./src/sass/**/*.scss', gulp.task( 'sass' ) );
// JS
gulp.watch(['./src/js/**/*.js'], gulp.parallel( 'js', 'jshint' ) );
// Minify Image
gulp.watch('./src/img/**/*', gulp.task( 'imagemin' ) );
// Done.
done();
});
// Build
gulp.task('build', gulp.parallel( 'copylib', 'js', 'sass', 'imagemin' ) );
// Default Tasks
gulp.task('default', gulp.parallel( 'watch' ) );