forked from vala-lang/valadoc-org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
108 lines (93 loc) · 2.18 KB
/
gulpfile.babel.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
103
104
105
106
107
108
/**
* gulpfile.babel.js
* Builds local assets for production environment
*/
import gulp from 'gulp'
import imagemin from 'gulp-imagemin'
import postcss from 'gulp-postcss'
import postcssPresetEnv from 'postcss-preset-env'
import babel from 'gulp-babel'
// All browsers we should _try_ to build for
const browsers = ['last 4 version', 'not ie <= 11']
/**
* images
* Compresses images for production
*
* @return {Task} - a gulp task
*/
gulp.task('images', () => {
const base = 'data/images'
const src = ['data/images/*']
const dest = 'valadoc.org/images'
return gulp.src(src, { base })
.pipe(imagemin())
.pipe(gulp.dest(dest))
})
/**
* scripts
* Copies scripts to production folder
*
* @return {Task} - a gulp task
*/
gulp.task('scripts', gulp.parallel(
function valadoc() {
const base = 'data/scripts'
const src = ['data/scripts/*.js']
const dest = 'valadoc.org/scripts'
return gulp.src(src, { base })
.pipe(babel({
presets: [
[
'@babel/preset-env',
{
"targets": browsers
}
]
]
}))
.pipe(gulp.dest(dest))
},
function fetchPolyfill() { // fetch polyfill
const base = 'node_modules/whatwg-fetch'
const src = ['node_modules/whatwg-fetch/*.js']
const dest = 'valadoc.org/scripts'
return gulp.src(src, { base })
.pipe(gulp.dest(dest))
}
))
/**
* styles
* Builds and compresses styles for production use
*
* @return {Task} - a gulp task
*/
gulp.task('styles', () => {
const base = 'data/styles'
const src = ['data/styles/*.css']
const dest = 'valadoc.org/styles'
return gulp.src(src, { base })
.pipe(postcss([
postcssPresetEnv({ browsers })
]))
.pipe(gulp.dest(dest))
})
/**
* php
* Copies over php files to production folder
*
* @return {Task} - a gulp task
*/
gulp.task('php', () => {
const base = 'data'
const src = ['data/**/*.php']
const dest = 'valadoc.org'
return gulp.src(src, { base })
.pipe(gulp.dest(dest))
})
/**
* default
* Runs all needed files for production environment
*
* @return {Task} - a gulp task
*/
gulp.task('default', gulp.parallel('images', 'scripts', 'styles', 'php'))