forked from ShorensteinCenter/Benchmarks-Program
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
executable file
·77 lines (69 loc) · 1.67 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'),
sass = require('gulp-sass'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify-es').default,
concat = require('gulp-concat'),
gutil = require('gulp-util'),
autoprefixer = require('gulp-autoprefixer'),
eslint = require('gulp-eslint');
// static and templates folders
const
static = 'app/static/',
templates = 'app/templates/'
// boostrap scss source
const bootstrap = {
in: './node_modules/bootstrap/'
};
// js
const js = {
in: [static + 'es/apiKeyForm.js',
static + 'es/listsTable.js',
static + 'es/emailForm.js'],
out: static + 'js/'
};
// scss
const scss = {
in: static + 'scss/main.scss',
out: static + 'css/',
outName: 'styles.min.css',
watch: static + 'scss/**/*',
sassOpts: {
outputStyle: 'compressed',
precision: 3,
includePaths: [bootstrap.in + 'scss']
}
};
// compile scss
gulp.task('scss', () => {
return gulp.src(scss.in)
.pipe(sass(scss.sassOpts))
.on('error', gutil.log)
.pipe(autoprefixer())
.pipe(rename(scss.outName))
.pipe(gulp.dest(scss.out));
});
// lint es
gulp.task('lint', () => {
return gulp.src(js.in)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
// uglify es
gulp.task('uglify', () => {
return gulp.src(js.in)
.pipe(concat('scripts.min.js'))
.pipe(uglify())
.on('error', gutil.log)
.pipe(gulp.dest(js.out));
});
// default task
gulp.task('default',
gulp.series(gulp.parallel('scss', gulp.series('lint', 'uglify')),
() => {
gulp.watch(scss.watch, gulp.series('scss'));
gulp.watch(js.in, gulp.series('lint', 'uglify'));
}
)
);