This repository has been archived by the owner on Nov 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
95 lines (86 loc) · 1.9 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
// Grab our gulp packages
const $ = require('gulp-load-plugins')({
pattern: ['*', '*/*'],
scope: ['devDependencies'],
});
const browserSync = $.browserSync.create();
const paths = {
url: 'blyth.test',
styles: {
watch: ['./assets/src/css/**/*.css'],
src: ['./assets/src/css/*.css'],
dest: './assets/css',
},
scripts: {
watch: ['./assets/src/js/**/*.js'],
src: './assets/src/js',
dest: 'assets/js',
},
assets: {
src: ['./assets/src/img/**/*.+(png|jpg|jpeg|gif|svg)'],
dest: './assets/img',
},
};
// Compiles sass into Assets
$.gulp.task('css', function () {
return $.gulp
.src(paths.styles.src)
.pipe(
$.postcss([
$.postcssImport(),
$.cssnano({
preset: [
'default',
{
calc: false,
},
],
}),
])
)
.pipe(
$.rename({
suffix: '.min',
})
)
.pipe($.gulp.dest(paths.styles.dest))
.pipe(browserSync.stream());
});
// Process and Optimizing Images
$.gulp.task('assets', function () {
return $.gulp
.src(paths.assets.src)
.pipe(
$.cache(
$.imagemin({
interlaced: true,
})
)
)
.pipe($.gulp.dest(paths.assets.dest));
});
// Watchers
$.gulp.task('watch', function () {
browserSync.init({
proxy: paths.url,
open: false,
notify: false,
});
$.gulp.watch(paths.styles.watch, $.gulp.series('css'));
$.gulp.watch(paths.scripts.watch, $.gulp.series('scripts'));
$.gulp.watch('**/*.php', reload);
$.gulp.watch('**/*.html', reload);
$.gulp.watch(paths.assets.src, $.gulp.series('assets'));
});
// Browsersync Helper
function reload(done) {
browserSync.reload();
done();
}
// Cleaning
$.gulp.task('clean', function (done) {
$.del.sync([paths.assets.dest]);
done();
});
// Build Sequences
$.gulp.task('default', $.gulp.parallel(['clean', 'css', 'assets', 'scripts']));