forked from Baremetrics/calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (48 loc) · 1.61 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
var gulp = require('gulp'),
ghPages = require('gulp-gh-pages'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
livereload = require('gulp-livereload'),
newer = require('gulp-newer');
// ROOT TASKS // ---------------------------------------------------------
// Main style task
gulp.task('css', function() {
return gulp.src('dev/sass/application.scss')
.pipe(sass())
.on('error', handleError)
.pipe(autoprefixer({cascade: false})) // auto prefix
.pipe(minifycss()) // minify everything
.pipe(gulp.dest('public/css'));
});
// Main Javascript task
gulp.task('js', function() {
return gulp.src('dev/js/**/*.js')
.pipe(newer('public/js'))
.pipe(uglify())
.on('error', handleError)
.pipe(gulp.dest('public/js'));
});
// Publish github page
gulp.task('deploy', function() {
return gulp.src('public/**/*')
.pipe(ghPages());
});
// FUNCTIONS // ---------------------------------------------------------
// Watch function
gulp.task('watch', function() {
gulp.start('js', 'css');
gulp.watch('dev/sass/**/*.scss', ['css']);
gulp.watch('dev/js/**/*.js', ['js']);
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);
});
// Default function
gulp.task('default', ['watch']);
// Error reporting function
function handleError(err) {
console.log(err.toString());
this.emit('end');
}