-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
97 lines (73 loc) · 2.42 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
var gulp = require('gulp');
var ghPages = require('gulp-gh-pages-will');
var sass = require('gulp-sass')(require('sass'));
var sourcemaps = require('gulp-sourcemaps');
var fileInclude = require('gulp-file-include');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
const del = require('del');
gulp.task('cleanup', () => {
return del('dist');
})
gulp.task('styles', function() {
return gulp.src('sass/*.scss')
.pipe(sourcemaps.init())
.pipe(sass.sync({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist/css'));
});
gulp.task('scripts', function() {
return gulp.src('js/*.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist/js'));
});
gulp.task('html', function() {
return gulp.src('*.html')
.pipe(fileInclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(gulp.dest('dist'));
});
gulp.task('fav', (done) => {
gulp.src('fav/*.ico')
.pipe(gulp.dest('dist'));
gulp.src(['fav/**.*', '!fav/*.ico'])
.pipe(gulp.dest('dist/img/icon'));
return done();
});
gulp.task('root', gulp.series('html', 'fav', () => {
return gulp.src(['*', '!*.html', '!README.md', '!*.js', '!*(package*).json', '!*.gitignore', '!sass', '!node_modules', '!dist', '!fav', '!partials'])
.pipe(gulp.dest('dist'));
})
);
gulp.task('img', function() {
return gulp.src('img/**/*.{gif,png,svg,jpg,jpeg}')
.pipe(imagemin([
imagemin.mozjpeg({ quality: 90, progressive: true}),
imagemin.gifsicle({ interlaced: true }),
imagemin.optipng({ optimizationLevel: 5 }),
imagemin.svgo()
], { verbose: true }))
.pipe(gulp.dest('dist/img'));
});
gulp.task('fonts', function() {
return gulp.src('fonts/*')
.pipe(gulp.dest('dist/fonts'));
});
gulp.task('deploy', function() {
return gulp.src('./dist/**/*')
.pipe(ghPages());
});
//Watch task
gulp.task('watch', (done) => {
gulp.watch('**/*.html', gulp.series('html'));
gulp.watch('sass/*.scss', gulp.series('styles'));
gulp.watch('js/*.js', gulp.series('scripts'));
gulp.watch('img/**.*', gulp.series('img'));
return done();
});
gulp.task('default', gulp.series('cleanup', 'styles', 'scripts', 'root', 'fonts', 'img', 'watch'));
gulp.task('dist', gulp.series('cleanup', 'styles', 'scripts', 'root', 'fonts', 'img'));