This repository has been archived by the owner on Apr 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
/
gulpfile.js
68 lines (54 loc) · 1.64 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
var gulp = require('gulp'),
ghPages = require('gulp-gh-pages'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
cleancss = require('gulp-clean-css'),
uglify = require('gulp-uglify'),
livereload = require('gulp-livereload'),
newer = require('gulp-newer');
// ROOT TASKS // ---------------------------------------------------------
// Main style task
function css(cb) {
gulp.src('dev/sass/**/**.scss')
.pipe(sass())
.on('error', handleError)
.pipe(autoprefixer({cascade: false, browsers: ['last 10 versions']})) // auto prefix
.pipe(cleancss()) // minify everything
.pipe(gulp.dest('public/css'));
cb();
}
// Main Javascript task
function js(cb) {
gulp.src('dev/js/**/*.js')
.pipe(newer('public/js'))
// .pipe(uglify())
.on('error', handleError)
.pipe(gulp.dest('public/js'));
cb();
}
// Publish github page
function deploy(cb) {
gulp.src('./public/**/*')
.pipe(ghPages());
cb();
}
// FUNCTIONS // ---------------------------------------------------------
// Watch function
function watch(cb) {
gulp.watch('dev/js/**/*.js', js);
gulp.watch('dev/sass/**/*.scss', css);
// gulp.watch('dev/img/**/*.{jpg,jpeg,png,gif,svg,ico}', img);
livereload.listen();
gulp.watch(['public/*.html', 'public/js/**/*.js', 'public/img/**/*.{jpg,jpeg,png,gif,svg,ico}', 'public/css/*.css']).on('change', livereload.changed);
cb();
}
// Error reporting function
function handleError(err) {
console.log(err.toString());
this.emit('end');
}
// Default function
exports.default = gulp.series(js, css, watch)
exports.css = css
exports.js = js
exports.deploy = deploy