forked from jonsuh/hamburgers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
101 lines (85 loc) · 2.5 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
98
99
100
101
var gulp = require('gulp');
var browserSync = require('browser-sync');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var csscomb = require('gulp-csscomb');
var cssnano = require('gulp-cssnano');
var eslint = require('gulp-eslint');
var notify = require('gulp-notify');
var plumber = require('gulp-plumber');
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var onError = function(err) {
notify.onError({
title: "Error",
message: "<%= error %>",
})(err);
this.emit('end');
};
var plumberOptions = {
errorHandler: onError,
};
var postCSSOptions = require('./config.postcss.json');
var autoprefixerOptions = postCSSOptions.autoprefixer;
gulp.task('sass', function() {
return gulp.src('_sass/screen.scss')
.pipe(plumber(plumberOptions))
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoprefixer(autoprefixerOptions))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('css'));
});
gulp.task('site:css', function() {
return gulp.src('css/**/*.css')
.pipe(csscomb('.csscomb.dist.json'))
.pipe(cssnano())
.pipe(gulp.dest('css'));
});
gulp.task('dist:css', function() {
return gulp.src('_sass/hamburgers/hamburgers.scss')
.pipe(sass())
.pipe(autoprefixer(autoprefixerOptions))
.pipe(gulp.dest('dist'))
.pipe(csscomb('.csscomb.dist.json'))
.pipe(cssnano())
.pipe(rename('hamburgers.min.css'))
.pipe(gulp.dest('dist'));
});
gulp.task('eslint', function() {
return gulp.src('_js/**/*.js')
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('concat', ['eslint'], function() {
return gulp.src([
'_js/hamburgers.js'
])
.pipe(sourcemaps.init())
.pipe(concat('hamburgers.js'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('js'));
});
gulp.task('site:js', function() {
return gulp.src([
'_js/**/*.js',
])
.pipe(uglify())
.pipe(gulp.dest('js'));
});
gulp.task('watch', function() {
var browserSyncConfig = require('./bs-config.js');
browserSync.init(browserSyncConfig);
gulp.watch('_sass/**/*.scss', ['sass']);
gulp.watch('_js/**/*.js', ['concat']);
});
gulp.task('build', ['sass', 'concat']);
gulp.task('site', ['build'], function() {
gulp.start('site:css');
gulp.start('site:js');
});
gulp.task('dist', ['dist:css']);
gulp.task('default', ['build', 'watch']);