-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
96 lines (70 loc) · 2.21 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const gulp = require('gulp'),
gutil = require('gulp-util' ),
sass = require('gulp-sass'),
browserSync = require('browser-sync'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
cleanCSS = require('gulp-clean-css'),
rename = require('gulp-rename'),
del = require('del'),
imagemin = require('gulp-imagemin'),
cache = require('gulp-cache'),
autoprefixer = require('gulp-autoprefixer'),
notify = require("gulp-notify");
gulp.task('sass', function() {
return gulp.src('scss/**/*.scss')
.pipe(sass({outputStyle: 'expand'}).on("error", notify.onError()))
.pipe(rename({suffix: '.min', prefix : ''}))
.pipe(autoprefixer(['last 15 versions']))
.pipe(cleanCSS())
.pipe(gulp.dest('css'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('js', function() {
return gulp.src([
'libs/jquery/dist/jquery.min.js',
'js/common.js'
])
.pipe(concat('scripts.min.js'))
//.pipe(uglify())
.pipe(gulp.dest('js'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: './'
},
notify: false,
});
});
gulp.task('imagemin', function() {
return gulp.src('img/**/*')
.pipe(cache(imagemin()))
.pipe(gulp.dest('dist/img'));
});
gulp.task('clean', async function() {
return del.sync('dist');
});
gulp.task('watch', function() {
gulp.watch('scss/**/*.scss', gulp.parallel('sass'));
gulp.watch(['libs/**/*.js', 'js/common.js'], gulp.parallel('js'));
gulp.watch('*.html', browserSync.reload);
});
gulp.task('prebuild', async function() {
let buildFiles = gulp.src([
'*.html'
]).pipe(gulp.dest('dist'));
let buildCss = gulp.src([
'css/main.min.css',
]).pipe(gulp.dest('dist/css'));
let buildJs = gulp.src([
'js/scripts.min.js',
]).pipe(gulp.dest('dist/js'));
let buildFonts = gulp.src([
'fonts/**/*',
]).pipe(gulp.dest('dist/fonts'));
});
gulp.task('clearcache', function () { return cache.clearAll(); });
gulp.task('build', gulp.parallel('prebuild', 'clean', 'imagemin', 'sass', 'js'));
gulp.task('default',gulp.parallel('watch', 'sass', 'js', 'browser-sync'));