-
Notifications
You must be signed in to change notification settings - Fork 19
/
gulpfile.js
77 lines (69 loc) · 1.63 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
const gulp = require('gulp');
const autoprefixer = require('gulp-autoprefixer');
const babel = require('gulp-babel');
const eslint = require('gulp-eslint');
const rename = require('gulp-rename');
const sass = require('gulp-sass');
const uglify = require('gulp-uglify');
const header = require('gulp-header');
const cleanCSS = require('gulp-clean-css');
const license = require('./scripts/header.js');
const paths = {
styles: {
src: './src/*.scss',
dest: './dist/',
},
scripts: {
src: './src/*.js',
dest: './dist/',
},
};
function js() {
return gulp
.src(paths.scripts.src)
.pipe(babel({ presets: ['@babel/preset-env'] }))
.pipe(header(license))
.pipe(gulp.dest(paths.scripts.dest))
.pipe(uglify())
.pipe(
rename({
suffix: '.min',
}),
)
.pipe(header(license))
.pipe(gulp.dest(paths.scripts.dest));
}
function lint() {
return gulp
.src(paths.scripts.src)
.pipe(eslint())
.pipe(eslint.format());
}
function css() {
return gulp
.src(paths.styles.src)
.pipe(sass().on('error', sass.logError))
.pipe(
autoprefixer({
cascade: false,
}),
)
.pipe(header(license))
.pipe(gulp.dest(paths.styles.dest))
.pipe(cleanCSS())
.pipe(
rename({
suffix: '.min',
}),
)
.pipe(gulp.dest(paths.styles.dest));
}
function watchFiles() {
gulp.watch(paths.scripts.src, gulp.parallel(lint, js));
gulp.watch(paths.styles.src, css);
}
const watch = gulp.series(gulp.parallel(lint, js, css), watchFiles);
const build = gulp.parallel(js, css);
exports.lint = lint;
exports.watch = watch;
exports.default = build;