forked from cypress-io/cypress-documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
112 lines (89 loc) · 2.91 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
const gulp = require('gulp')
const RevAll = require('gulp-rev-all')
const clean = require('gulp-clean')
const runSequence = require('run-sequence')
const revisionOpts = {
dontGlobal: ['.ico', 'sitemap.xml', 'sitemap.xsl', 'logo.png'],
dontRenameFile: ['.html', 'CNAME'],
dontUpdateReference: ['.html'],
dontSearchFile: ['.js'],
debug: process.env.NODE_ENV === 'production',
}
function remove (folder) {
return gulp
.src(folder)
.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: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:fira:fonts', function () {
return gulp
.src('./node_modules/fira/**')
.pipe(gulp.dest('./themes/cypress/source/fonts/vendor/fira'))
})
gulp.task('move:font:awesome:fonts', (cb) => {
runSequence('move:font:awesome:css', 'move:font:awesome:fonts:folder', cb)
})
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('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'))
})
gulp.task('clean:js', ['clean:js:folders', 'clean:non:application:js'])
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:css', () => {
return remove('public/css/!(style|prism-coy).css')
})
gulp.task('clean:tmp', () => {
return remove('tmp')
})
gulp.task('clean:public', () => {
return remove('public')
})
gulp.task('pre:build', ['copy:static:assets'])
gulp.task('post:build', (cb) => {
runSequence('clean:js', 'clean:css', 'revision', 'clean:public', 'copy:tmp:to:public', 'clean:tmp', cb)
})
gulp.task('copy:static:assets', ['move:menu:spy:js', 'move:scrolling:element:js', 'move:doc:search:js', 'move:doc:search:css', 'move:fira:fonts', 'move:font:awesome:fonts'])