-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·65 lines (51 loc) · 1.94 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
'use strict'
const connect = require('gulp-connect')
const path = require('path')
const gulp = require('gulp')
const build = require('./tasks/build')
const buildPreview = require('./tasks/build-preview')
const format = require('./tasks/format')
const lintCss = require('./tasks/lint-css')
const lintJs = require('./tasks/lint-js')
const pack = require('./tasks/pack')
const preview = require('./tasks/preview')
const release = require('./tasks/release')
const update = require('./tasks/update')
const bundleName = 'ui'
const buildDir = process.env.CONTEXT === 'deploy-preview' ? 'public/dist' : 'build'
const previewSiteSrcDir = 'preview-site-src'
const previewSiteDestDir = 'public'
const srcDir = 'src'
const destDir = path.join(previewSiteDestDir, '_')
const cssFiles = [path.join(srcDir, 'css/**/*.css'), `!${path.join(srcDir, 'css/**/*.min.css')}`]
const jsFiles = [
'gulpfile.js',
'tasks/**/*.js',
path.join(srcDir, '{helpers,js}/**/*.js'),
`!${path.join(srcDir, '{helpers,js}/**/*.min.js')}`,
]
gulp.task('lint:css', () => lintCss(cssFiles))
gulp.task('lint:js', () => lintJs(jsFiles))
gulp.task('lint', ['lint:css', 'lint:js'])
gulp.task('format', () => format(jsFiles))
gulp.task('build', function () {
return build(srcDir, destDir, this.seq.slice(0).pop() === 'preview')
})
gulp.task('build:preview', ['build'], () =>
buildPreview(srcDir, destDir, previewSiteSrcDir, previewSiteDestDir, connect.reload)
)
gulp.task('preview', ['build:preview'], () =>
preview(previewSiteDestDir, {
port: 5252,
livereload: process.env.LIVERELOAD === 'true',
watch: {
src: [srcDir, previewSiteSrcDir],
onChange: () => gulp.start('build:preview'),
},
})
)
gulp.task('pack', ['build', 'lint'], () => pack(destDir, buildDir, bundleName))
gulp.task('release', ['pack'], () =>
release(buildDir, bundleName, 'mulesoft', 'docs-site-antora-ui', process.env.GITHUB_TOKEN))
gulp.task('default', ['build'])
gulp.task('update', () => update())