forked from bonitasoft/bonita-documentation-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
130 lines (111 loc) · 3.47 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
'use strict'
const { parallel, series, watch } = require('gulp')
const createTask = require('./gulp.d/lib/create-task')
const exportTasks = require('./gulp.d/lib/export-tasks')
const log = require('fancy-log')
const bundleName = 'ui'
const buildDir = 'build'
const previewSrcDir = 'preview-src'
const previewDestDir = 'public'
const srcDir = 'src'
const destDir = `${previewDestDir}/_`
const { reload: livereload } = process.env.LIVERELOAD === 'true' ? require('gulp-connect') : {}
const serverConfig = { host: '0.0.0.0', port: 5252, livereload }
const task = require('./gulp.d/tasks')
const glob = {
all: [srcDir, previewSrcDir],
scss: `${srcDir}/stylesheets/**/*.scss`,
js: ['gulpfile.js', 'gulp.d/**/*.js', `${srcDir}/{helpers,js}/**/*.js`],
}
// Do not lint vendor prod ready files (exclude *.min.js)
glob.jsToLint = Array.from(glob.js)
glob.jsToLint = glob.jsToLint.concat([`!${srcDir}/{helpers,js}/**/*.min.js`])
const cleanTask = createTask({
name: 'clean',
desc: 'Clean files and folders generated by build',
call: task.remove(['build', 'public']),
})
const lintJsTask = createTask({
name: 'lint:js',
desc: 'Lint the JavaScript source files using eslint (JavaScript Standard Style)',
call: task.lintJs(glob.jsToLint),
})
// eslint-disable-next-line no-unused-vars
const lintScssTask = createTask({
name: 'lint:scss',
desc: 'Lint the JavaScript source files using eslint (JavaScript Standard Style)',
call: task.lintScss(glob.scss),
})
const lintTask = createTask({
name: 'lint',
desc: 'Lint the JavaScript source files',
call: parallel(lintJsTask),
})
const formatTask = createTask({
name: 'format',
desc: 'Format the JavaScript source files using prettify (JavaScript Standard Style)',
call: task.format(glob.js),
})
const buildTask = createTask({
name: 'build',
desc: 'Build and stage the UI assets for bundling',
call: task.build(
srcDir,
destDir,
process.argv.slice(2).some((name) => name.startsWith('preview'))
),
})
const bundleBuildTask = createTask({
name: 'bundle:build',
call: series(cleanTask, lintTask, buildTask),
})
const bundlePackTask = createTask({
name: 'bundle:pack',
desc: 'Create a bundle of the staged UI assets for publishing',
call: task.pack(
destDir,
buildDir,
bundleName,
(bundlePath) => !process.env.CI && log(`Antora option: --ui-bundle-url=${bundlePath}`)
),
})
const bundleTask = createTask({
name: 'bundle',
desc: 'Clean, lint, build, and bundle the UI for publishing',
call: series(bundleBuildTask, bundlePackTask),
})
const packTask = createTask({
name: 'pack',
desc: '(deprecated; use bundle instead)',
call: series(bundleTask),
})
const buildPreviewPagesTask = createTask({
name: 'preview:build-pages',
call: task.buildPreviewPages(srcDir, previewSrcDir, previewDestDir, livereload),
})
const previewBuildTask = createTask({
name: 'preview:build',
desc: 'Process and stage the UI assets and generate pages for the preview',
call: parallel(buildTask, buildPreviewPagesTask),
})
const previewServeTask = createTask({
name: 'preview:serve',
call: task.serve(previewDestDir, serverConfig, () => watch(glob.all, previewBuildTask)),
})
const previewTask = createTask({
name: 'preview',
desc: 'Generate a preview site and launch a server to view it',
call: series(previewBuildTask, previewServeTask),
})
module.exports = exportTasks(
bundleTask,
cleanTask,
lintTask,
formatTask,
buildTask,
bundleTask,
bundlePackTask,
previewTask,
previewBuildTask,
packTask
)