-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
101 lines (89 loc) · 2.88 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
97
98
99
100
101
var gulp = require('gulp'),
sass = require('gulp-sass'),
fileinclude = require('gulp-file-include'),
clean = require('gulp-clean'),
browserSync = require('browser-sync').create(),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
cleancss = require('gulp-clean-css'),
rename = require('gulp-rename'),
autoprefixer = require('gulp-autoprefixer'),
imagemin = require('gulp-imagemin'),
notify = require('gulp-notify');
gulp.task('clean', function() {
return gulp.src('build/')
.pipe(clean());
});
gulp.task('html', function() {
return gulp.src('app/*.html')
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(gulp.dest('build/'))
.pipe(browserSync.reload({ stream: true }))
});
gulp.task('php', function() {
return gulp.src('app/*.php')
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(gulp.dest('build/'))
.pipe(browserSync.reload({ stream: true }))
});
gulp.task('html-file-include', function() {
return gulp.src('app/includes/**/*')
.pipe(gulp.dest('build/includes/'))
.pipe(browserSync.reload({ stream: true }))
});
gulp.task('styles', function() {
return gulp.src('app/sass/*.sass')
.pipe(sass({ outputStyle: 'expanded' }).on("error", notify.onError()))
.pipe(rename({ suffix: '.min', prefix : '' }))
.pipe(autoprefixer(['last 10 versions']))
.pipe(cleancss( {level: { 1: { specialComments: 0 } } }))
.pipe(gulp.dest('build/css'))
.pipe(browserSync.stream())
});
gulp.task('scripts', function() {
return gulp.src([
'app/js/**/*'
])
.pipe(concat('scripts.min.js'))
.pipe(uglify())
.pipe(gulp.dest('build/js'))
.pipe(browserSync.reload({ stream: true }))
});
gulp.task('libs', function() {
return gulp.src('app/libs/**/*')
.pipe(gulp.dest('build/libs/'))
.pipe(browserSync.reload({ stream: true }))
});
gulp.task('images', function() {
return gulp.src('app/img/**/*')
.pipe(imagemin())
.pipe(gulp.dest('build/img/'))
.pipe(browserSync.reload({ stream: true }))
});
gulp.task('fonts', function() {
return gulp.src('app/fonts/**/*')
.pipe(gulp.dest('build/fonts/'))
.pipe(browserSync.reload({ stream: true }))
});
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: 'build'
},
notify: false
})
});
gulp.task('watch', function() {
gulp.watch('app/**/*.html', gulp.parallel('html'));
gulp.watch('app/sass/**/*.sass', gulp.parallel('styles'));
gulp.watch(['libs/**/*.js', 'app/js/*.js'], gulp.parallel('scripts'));
gulp.watch('app/img/**/*', gulp.parallel('images'));
gulp.watch('app/fonts/*.*', gulp.parallel('fonts'));
});
gulp.task('default', gulp.parallel('html', 'php', 'html-file-include', 'styles', 'fonts', 'scripts', 'libs', 'images', 'browser-sync', 'watch'));