-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
86 lines (76 loc) · 2.39 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
var critical = require('critical')
var uglify = require('gulp-terser')
const { dest, src, task, series } = require('gulp')
task('minify', async function (cb) {
src('dist/assets/main.bundle.js').pipe(uglify()).pipe(dest('dist/assets'))
})
// task('minify', async function (cb) {
// src('dist/**/*.{html,css,js}')
// .pipe(uglify())
// .pipe(dest('dist'))
// })
// var criticalCss = require('gulp-penthouse')
// const injectInline = require('@exuanbo/gulp-inject-inline')
task('critical', async function (cb) {
// src('./dist/assets/main.bundle.css')
// .pipe(
// criticalCss({
// out: 'critical.css', // output file name
// url: './dist/index.html', // url from where we want penthouse to extract critical styles
// width: 1300, // max window width for critical media queries
// height: 900, // max window height for critical media queries
// strict: true,
// // userAgent:
// // 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)', // pretend to be googlebot when grabbing critical page styles.
// })
// )
// // .pipe(
// // cssNano({
// // safe: true, // this isn't required, but I've included cssNano to minify the output file
// // })
// // )
// .pipe(dest('./dist/static/css/'))
critical.generate({
inline: true,
base: 'dist/',
src: 'index.html',
css: ['assets/main.bundle.css'],
dimensions: [
{
height: 500,
width: 300,
},
{
height: 720,
width: 1280,
},
],
target: {
css: 'assets/crit.bundle.css',
html: 'index.html',
uncritical: 'assets/rest.bundle.min.css',
},
extract: true,
// ignore: {
// atrule: ['@font-face', '@import'],
// },
})
})
// task('critical-inject', async function (cb) {
// src('./dist/**/*.html').pipe(injectInline()).pipe(dest('dist'))
// })
var gulpBrotli = require('gulp-brotli')
task('compress', async function (cb) {
src('dist/**/*.{html,css,js}', { buffer: false })
.pipe(gulpBrotli.compress())
.pipe(dest('dist'))
})
// task('critical', series('critical-extract', 'critical-inject'))
task('build', series('minify', 'critical'))
// var gzip = require("gulp-gzip");
// gulp.task("compress", function () {
// gulp
// .src("./dev/scripts/*.js")
// .pipe(gzip())
// .pipe(gulp.dest("./public/scripts"));
// });