-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
82 lines (75 loc) · 1.91 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
82
const gulp = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const autoprefixer = require('gulp-autoprefixer');
const concat = require('gulp-concat');
const browserSync = require('browser-sync').create();
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
function compilaSass() {
return gulp
.src('./scss/**/*.scss')
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(
autoprefixer({
overrideBrowserslist: ['last 2 versions'],
cascade: false,
}),
)
.pipe(gulp.dest('./css'))
.pipe(browserSync.stream());
}
function browsersync() {
browserSync.init({
server: {
baseDir: './',
},
});
}
function gulpJs() {
return gulp
.src('./js/scripts/**/*.js')
.pipe(concat('all.js'))
.pipe(
babel({
presets: ['@babel/env'],
}),
)
.pipe(uglify())
.pipe(gulp.dest('./js/'))
.pipe(browserSync.stream());
}
function pluginJs() {
return gulp
.src(['./js/lib/*.min.js'])
.pipe(concat('plugins.js'))
.pipe(gulp.dest('./js/'))
.pipe(browserSync.stream());
}
function pluginsCss() {
return gulp
.src(['./css/lib/*.css'])
.pipe(concat('plugins.css'))
.pipe(gulp.dest('./css/'))
.pipe(browserSync.stream());
}
function watchFunc() {
gulp.watch('./scss/**/*.scss', compilaSass);
gulp.watch('./css/lib/*.css', pluginsCss);
gulp.watch('./*.html').on('change', browserSync.reload);
gulp.watch('./js/scripts/*.js', gulpJs);
gulp.watch('./js/lib/*.js', pluginJs);
}
exports.sass = compilaSass;
exports.browsersync = browsersync;
exports.gulpJs = gulpJs;
exports.pluginJs = pluginJs;
exports.pluginsCss = pluginsCss;
exports.watch = watchFunc;
exports.default = gulp.parallel(
watchFunc,
gulpJs,
pluginJs,
pluginsCss,
compilaSass,
browsersync,
);