-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
81 lines (72 loc) · 2.12 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
'use strict';
const gulp = require('gulp');
const autoprefixer = require('gulp-autoprefixer');
const babelify = require('babelify');
const browserify = require('browserify');
const buffer = require('vinyl-buffer');
const cleanCSS = require('gulp-clean-css');
const eslint = require('gulp-eslint');
const rename = require('gulp-rename');
const sass = require('gulp-sass')(require('sass'));
const source = require('vinyl-source-stream');
const stylelint = require('gulp-stylelint');
const uglify = require('gulp-uglify');
const zip = require('gulp-zip');
gulp.task('stylelint', () => {
return gulp.src([
'./_assets/scss/**/*.scss',
'!./_assets/scss/vendor/_normalize.scss',
'!./_assets/scss/fonts/*.scss'
])
.pipe(stylelint({
reporters: [
{formatter: 'string', console: true}
]
}));
});
gulp.task('sass', () => {
return gulp.src('./_assets/scss/app.scss')
.pipe(sass().on('error', sass.logError))
.pipe(cleanCSS())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./assets/css'));
});
gulp.task('lint', () => {
return gulp.src([
'./_assets/js/components/_formspree.js',
'./_assets/js/components/_infiniteScroll.js',
'./_assets/js/components/_miscellaneous.js',
'./_assets/js/components/_pageTransition.js',
'./_assets/js/components/_popup.js',
'./_assets/js/_inits.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('browserify', () => {
return browserify('./_assets/js/app.js')
.transform('babelify', {presets: ['@babel/preset-env']})
.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./assets/js'));
});
gulp.task('zip', () => {
return gulp.src([
'./**',
'!./.DS_Store',
'!./.git',
'!./node_modules/**'
])
.pipe(zip('barber-jekyll.zip'))
.pipe(gulp.dest('../'))
});
gulp.task('build', gulp.series('sass', 'browserify'));
gulp.task('watch', () => {
gulp.watch('./_assets/scss/**/*.scss', gulp.series('sass'));
gulp.watch('./_assets/js/**/*.js', gulp.series('browserify'));
});
gulp.task('default', gulp.series('build', 'watch'));