-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
58 lines (51 loc) · 1.44 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
// Load Node Modules/Plugins
import gulp from 'gulp';
import pug from 'gulp-pug';
import concat from 'gulp-concat';
import uglify from 'gulp-uglify';
import jshint from 'gulp-jshint';
import sassLoader from 'sass';
import gulpSass from 'gulp-sass';
import gulpBabel from 'gulp-babel';
// const imagemin = require('gulp-imagemin');
const sass = gulpSass(sassLoader);
const { src, dest, lastRun, series, parallel, watch } = gulp;
function html() {
return src(['src/pug/*.pug'], { since: lastRun(html) })
.pipe(
pug({
pretty: true,
})
)
.pipe(dest('dist/'));
}
function css() {
return src(['src/scss/*.scss'])
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(dest('dist/frontend/css'));
}
function scripts() {
return src(['src/js/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(
gulpBabel({
presets: ['@babel/env'],
plugins: ['@babel/transform-runtime'],
})
)
.pipe(concat('all.js'))
.pipe(uglify())
.pipe(dest('dist/frontend/js'));
}
function images() {
return gulp.src(['src/images/**']).pipe(dest('dist/frontend/images'));
}
function watchFiles() {
watch('src/pug/**/*.pug', series(html));
watch('src/scss/**/*.scss', series(css));
watch('src/js/**', series(scripts));
watch('src/images/**', series(images));
}
const _default = series(css, parallel(scripts, images), watchFiles);
export { _default as default };