This repository has been archived by the owner on Oct 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
executable file
·70 lines (56 loc) · 1.68 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var sasslint = require('gulp-sass-lint');
var eslint = require('gulp-eslint');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var imagemin = require('gulp-imagemin');
var SASS = 'sass';
var CSS = 'css';
var IMG = 'img';
var JS = 'js';
var sassOptions = {
includePaths: ['./node_modules/breakpoint-sass/stylesheets']
};
// tasks
gulp.task('sass', done => {
gulp.src(SASS + '/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass.sync(sassOptions).on('error', sass.logError))
.pipe(autoprefixer({}))
.pipe(sourcemaps.write('../css'))
.pipe(gulp.dest(CSS));
done();
});
gulp.task('sass-lint', done => {
gulp.src(SASS + '/**/*.scss')
.pipe(sasslint())
.pipe(sasslint.format())
.pipe(sasslint.failOnError())
done();
});
gulp.task('js-lint', done => {
gulp.src(JS + '/**/*.js')
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
done();
});
gulp.task('imagemin', done => {
gulp.src(IMG + '/src/*')
.pipe(imagemin())
.pipe(gulp.dest(IMG));
done();
});
// build without lint
gulp.task('build', gulp.series('sass', 'imagemin'));
gulp.task('watch', function () {
return gulp.watch(SASS + '/**/*.scss', gulp.series(gulp.series('sass', 'imagemin')));
});
// build with lint
gulp.task('build-lint', gulp.series('sass-lint', 'sass', 'imagemin', 'js-lint'));
gulp.task('watch-lint', function () {
return gulp.watch(SASS + '/**/*.scss', gulp.series(gulp.series('sass-lint', 'sass', 'imagemin', 'js-lint')));
});
gulp.task('default', gulp.series('build', 'watch'));
// gulp.task('default', gulp.series('build-lint', 'watch-lint'));