-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgulpfile.js
executable file
·78 lines (61 loc) · 2.09 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
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var cleanCSS = require('gulp-clean-css');
var jade = require('gulp-jade');
gulp.task('sass', function() {
return gulp.src('src/assets/css/main.scss')
.pipe(plumber({errorHandler: errorAlert}))
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoprefixer())
.pipe(sourcemaps.write('../sourcemaps'))
.pipe(gulp.dest('assets/css'))
.pipe(browserSync.stream())
.pipe(cleanCSS())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('assets/css'));
});
gulp.task('jade', function() {
return gulp.src('src/*.jade')
.pipe(jade())
.pipe(gulp.dest('./'));
});
gulp.task('js', function() {
return gulp.src(['src/assets/js/chance.min.js', 'src/assets/js/holder-ipsum.min.js', 'src/assets/js/dummi.js'])
.pipe(plumber({errorHandler: errorAlert}))
.pipe(sourcemaps.init())
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('../sourcemaps'))
.pipe(gulp.dest('assets/js'))
});
function reload() {
return browserSync.reload();
}
gulp.task('jade-reload', ['jade'], reload);
gulp.task('js-reload', ['js'], reload);
gulp.task('serve', ['sass', 'js', 'jade'], function() {
browserSync.init({
server: {
baseDir: './'
}
});
gulp.watch(['src/assets/css/**/*.scss', 'src/assets/css/**/*.sass', 'src/assets/css/main.scss'], ['sass']);
gulp.watch('src/assets/js/*.js', ['js-reload']);
gulp.watch(['src/*.jade', 'src/includes/*.jade'], ['jade-reload']);
});
gulp.task('default', ['serve']);
function errorAlert(error) {
notify.onError({title: 'Gulp Error', message: 'Beep beep beep, stuffs going down. Check the console.', sound: true})(error);
console.log(error.toString());
this.emit('end');
}