-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
51 lines (46 loc) · 1.41 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
let { existsSync, createWriteStream } = require('fs')
let { join, dirname } = require('path')
let { rm, mkdir } = require('fs/promises')
let { get } = require('https')
let gulp = require('gulp')
// Benchmark
gulp.task('clean', async () => {
await rm(join(__dirname, 'cache'), { recursive: true, force: true })
})
gulp.task('bootstrap', async () => {
let cache = join(__dirname, 'cache', 'bootstrap.css')
await mkdir(dirname(cache), { recursive: true })
if (existsSync(cache)) return
await new Promise((resolve, reject) => {
let file = createWriteStream(cache)
file.on('finish', () => resolve())
get(
'https://raw.githubusercontent.com/' +
'twbs/bootstrap/main/dist/css/bootstrap.css',
res => {
if (res.statusCode !== 200) {
reject(new Error(`Failed to get Bootstrap: ${res.statusCode}`))
return
}
res.pipe(file)
}
)
})
})
for (let name of ['preprocessors', 'parsers', 'prefixers', 'tokenizers']) {
gulp.task(
name,
gulp.series('bootstrap', () => {
let bench = require('gulp-bench')
let summary = require('gulp-bench-summary')
let benchmark = gulp.src(`./${name}.js`, { read: false }).pipe(bench())
return benchmark.pipe(
summary(name === 'prefixers' ? 'Autoprefixer' : 'PostCSS')
)
})
)
}
gulp.task(
'default',
gulp.series('preprocessors', 'parsers', 'prefixers', 'tokenizers')
)