-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
72 lines (61 loc) · 1.76 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
const gulp = require('gulp');
const gulpSass = require('gulp-sass')(require('sass'));
const gulpAutoprefixer = require('gulp-autoprefixer');
const gulpConcat = require('gulp-concat');
const gulpBabel = require('gulp-babel');
const gulpUglify = require('gulp-uglify');
const browserSync = require('browser-sync').create();
function sassAutoPrefixer() {
return gulp
.src('public/css/src/*.scss')
.pipe(
gulpSass({
outputStyle: 'compressed',
})
)
.pipe(
gulpAutoprefixer({
cascade: false,
})
)
.pipe(gulp.dest('public/css/dest'))
.pipe(browserSync.stream());
}
function js() {
return gulp
.src('public/js/src/*.js')
.pipe(gulpConcat('app.js'))
.pipe(
gulpBabel({
presets: ['@babel/preset-env'],
})
)
.pipe(gulpUglify())
.pipe(gulp.dest('public/js/dest'))
.pipe(browserSync.stream());
}
function browser() {
browserSync.init({
server: {
baseDir: './',
},
});
}
function pluginJs() {
return gulp
.src(['node_modules/scrollreveal/dist/scrollreveal.min.js', 'public/js/dest/plugin.js'])
.pipe(gulpConcat('plugin.js'))
.pipe(gulp.dest('public/js/dest'))
.pipe(browserSync.stream());
}
function watch() {
gulp.watch('public/css/src/*.scss', sassAutoPrefixer);
gulp.watch('public/js/src/*.js', js);
gulp.watch(['*.html']).on('change', browserSync.reload);
}
exports.sassAutoPrefixer = sassAutoPrefixer;
exports.js = js;
exports.pluginJs = pluginJs;
exports.browser = browser;
exports.watch = watch;
exports.default = gulp.parallel(sassAutoPrefixer, watch, browser, js, pluginJs);