This repository has been archived by the owner on Jun 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
102 lines (94 loc) · 2.56 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
102
const gulp = require('gulp');
const uglifyes = require('uglify-es');
const composer = require('gulp-uglify/composer');
const minifyCSS = require('gulp-csso');
const postcss = require('gulp-postcss');
const postcssPresetEnv = require('postcss-preset-env');
const sourcemaps = require('gulp-sourcemaps');
const html = require('gulp-minify-html');
const imagemin = require('gulp-imagemin');
const concat = require('gulp-concat');
const uglify = composer(uglifyes, console);
// Move fonts
gulp.task('fonts', () => {
return gulp.src('src/fonts/*.woff2')
.pipe(gulp.dest('public/fonts'));
});
// Compress images
gulp.task('images', () => {
return gulp.src('src/img/*')
.pipe(imagemin([
imagemin.gifsicle({
interlaced: true
}),
imagemin.jpegtran({
progressive: true
}),
imagemin.optipng({
optimizationLevel: 5
}),
imagemin.svgo({
plugins: [{
removeViewBox: true
},
{
cleanupIDs: false
}
]
})
], {
verbose: true
}))
.pipe(gulp.dest('public/img'))
});
// Concatenate JavaScript files and create "main.min.js"
gulp.task('scripts', () => {
return gulp.src('src/js/transformed.js')
.pipe(concat('main.min.js'))
.pipe(uglify())
.pipe(gulp.dest('public/js'));
});
// Concatenate stylesheetss
gulp.task('stylesheet', () => {
return gulp.src('src/**/*.css')
//.pipe(sourcemaps.init())
.pipe(postcss(
[
require('precss'),
require('autoprefixer'),
postcssPresetEnv({
stage: 3,
browsers: 'last 2 versions'
})
]
))
//.pipe(sourcemaps.write('.'))
.pipe(concat('style.min.css'))
.pipe(minifyCSS())
.pipe(gulp.dest('public/css'));
});
// Minify HTML files
gulp.task('html', () => {
return gulp.src('src/index.html')
.pipe(html())
.pipe(gulp.dest('public/'));
});
// Service Worker
gulp.task('ServiceWorker', () => {
return gulp.src('src/sw.js')
.pipe(gulp.dest('public/'));
});
// Manifest
gulp.task('manifest', () => {
return gulp.src('src/manifest.json')
.pipe(gulp.dest('public/'));
});
gulp.task('default', gulp.series([
'fonts',
'images',
'scripts',
'stylesheet',
'html',
'ServiceWorker',
'manifest'
]));