forked from cypress-io/cypress-documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
133 lines (102 loc) · 3.61 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
const gulp = require('gulp')
const RevAll = require('gulp-rev-all')
const clean = require('gulp-clean')
const revisionOpts = {
dontGlobal: ['.ico', 'sitemap.xml', 'sitemap.xsl', 'logo.png', '[email protected]'],
dontRenameFile: ['.html', 'CNAME'],
dontUpdateReference: ['.html'],
dontSearchFile: ['.js'],
debug: process.env.NODE_ENV === 'production',
}
function remove (folder) {
return gulp
.src(folder, { allowEmpty: true })
.pipe(clean())
}
function moveJSNodeModule (path) {
return gulp
.src(`./node_modules/${path}`)
.pipe(gulp.dest('./themes/cypress/source/js/vendor'))
}
function moveCSSNodeModule (path) {
return gulp
.src(`./node_modules/${path}`)
.pipe(gulp.dest('./themes/cypress/source/css/vendor'))
}
gulp.task('move:menu:spy:js', function () {
return moveJSNodeModule('menuspy/dist/menuspy.js')
})
gulp.task('move:doc:yall:js', function () {
return moveJSNodeModule('yall/dist/yall-2.0.1.min.js')
})
gulp.task('move:scrolling:element:js', function () {
return moveJSNodeModule('scrollingelement/scrollingelement.js')
})
gulp.task('move:doc:search:js', function () {
return moveJSNodeModule('docsearch.js/dist/cdn/docsearch.js')
})
gulp.task('move:doc:search:css', function () {
return moveCSSNodeModule('docsearch.js/dist/cdn/docsearch.css')
})
// move font files
gulp.task('move:roboto:fonts:folder', function () {
return gulp
.src('./node_modules/roboto-fontface/fonts/**')
.pipe(gulp.dest('./themes/cypress/source/fonts/vendor/roboto-fontface/fonts'))
})
gulp.task('move:roboto:css', function () {
return gulp
.src('./node_modules/roboto-fontface/css/**')
.pipe(gulp.dest('./themes/cypress/source/fonts/vendor/roboto-fontface/css'))
})
gulp.task('move:roboto:fonts', gulp.series('move:roboto:css', 'move:roboto:fonts:folder'))
gulp.task('move:font:awesome:css', function () {
return gulp
.src('./node_modules/font-awesome/css/font-awesome.css')
.pipe(gulp.dest('./themes/cypress/source/fonts/vendor/font-awesome/css'))
})
gulp.task('move:font:awesome:fonts:folder', function () {
return gulp
.src('./node_modules/font-awesome/fonts/*')
.pipe(gulp.dest('./themes/cypress/source/fonts/vendor/font-awesome/fonts'))
})
gulp.task('move:font:awesome:fonts', gulp.series('move:font:awesome:css', 'move:font:awesome:fonts:folder'))
gulp.task('revision', () => {
return gulp
.src('public/**')
.pipe(RevAll.revision(revisionOpts))
.pipe(gulp.dest('tmp'))
})
gulp.task('copy:tmp:to:public', () => {
return gulp
.src('tmp/**')
.pipe(gulp.dest('public'))
})
// move robots.txt
gulp.task('move:robots.txt:to:public', function () {
return gulp
.src('./robots.txt*')
.pipe(gulp.dest('public'))
})
gulp.task('clean:non:application:js', () => {
return remove('public/js/!(application).js')
})
gulp.task('clean:js:folders', () => {
return remove('public/js/vendor')
})
gulp.task('clean:js', gulp.parallel('clean:js:folders', 'clean:non:application:js'))
gulp.task('clean:css', () => {
return remove('public/css/!(style|prism-coy).css')
})
gulp.task('clean:fonts:folders', () => {
return remove('public/fonts/vender')
})
gulp.task('clean:tmp', () => {
return remove('tmp')
})
gulp.task('clean:public', () => {
return remove('public')
})
gulp.task('copy:static:assets', gulp.parallel('move:menu:spy:js', 'move:scrolling:element:js', 'move:doc:search:js', 'move:doc:yall:js', 'move:doc:search:css', 'move:roboto:fonts', 'move:font:awesome:fonts'))
gulp.task('pre:build', gulp.parallel('copy:static:assets'))
gulp.task('post:build', gulp.series('clean:js', 'clean:css', 'clean:fonts:folders', 'revision', 'clean:public', 'copy:tmp:to:public', 'move:robots.txt:to:public', 'clean:tmp'))