forked from squarechip/timeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·81 lines (74 loc) · 2.15 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
const gulp = require('gulp');
const babel = require('gulp-babel');
const eslint = require('gulp-eslint');
const sass = require('gulp-sass');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const imagemin = require('gulp-imagemin');
const livereload = require('gulp-livereload');
const cleanCSS = require('gulp-clean-css');
const plumber = require('gulp-plumber');
const postcss = require('gulp-postcss');
const cssnext = require('postcss-cssnext');
const pxtorem = require('postcss-pxtorem');
const reporter = require('postcss-reporter');
const syntaxScss = require('postcss-scss');
const header = require('gulp-header');
const banner = [
'/**',
' * Timeline - a horizontal / vertical timeline component',
' * v. 1.1.4',
' * Copyright Mike Collins',
' * MIT License',
' */',
'',
].join('\n');
gulp.task('build-js', () => gulp
.src('src/js/timeline.js')
.pipe(plumber())
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.pipe(babel({
presets: ['env'],
}))
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(header(banner))
.pipe(gulp.dest('dist/js/'))
.pipe(livereload()));
gulp.task('build-css', () => {
const processors = [
cssnext({ browsers: ['last 5 versions'] }),
pxtorem({
propWhiteList: ['font-size', 'padding', 'line-height', 'letter-spacing', 'margin'],
mediaQuery: true,
replace: true,
}),
reporter({
clearMessages: true
})
];
return gulp
.src('src/scss/timeline.scss')
.pipe(plumber())
.pipe(sass())
.pipe(postcss(processors), { syntax: syntaxScss })
.pipe(rename({ suffix: '.min' }))
.pipe(cleanCSS())
.pipe(gulp.dest('dist/css/'))
.pipe(livereload());
});
gulp.task('images', () => gulp
.src('src/images/**')
.pipe(imagemin())
.pipe(gulp.dest('dist/images'))
.pipe(livereload()));
gulp.task('watch', () => {
livereload.listen();
gulp.watch('src/scss/*.scss', gulp.series('build-css'));
gulp.watch('src/images/**', gulp.series('images'));
gulp.watch('src/js/timeline.js', gulp.series('build-js'));
});
// Default Task
gulp.task('default', gulp.parallel('build-js', 'build-css', 'images'));