Commit 715626c6 authored by Dan Allen's avatar Dan Allen

consolidate Gulp build

- move task require to gulpfile.js/tasks/index.js
- abbreviate variable names
- use ospath where appropriate
parent 7367f6c1
Pipeline #41674869 (#120) failed with stages
in 1 minute and 39 seconds
......@@ -158,6 +158,10 @@ If you need to bundle the UI in order to preview the UI on the real site in loca
The UI bundle will be available at [.path]_build/ui-bundle.zip_.
You can then point Antora at this bundle using the `--ui-bundle-url` command-line option.
If you have the preview running, and you want to bundle without causing the preview to be clobbered, use:
$ gulp bundle:pack
== Copyright and License
Copyright (C) 2017-2018 OpenDevise Inc. and the Antora Project.
......
'use strict'
const { parallel, series, tree } = require('gulp')
const camelCase = (name) => name.replace(/[-]./g, (m) => m.substr(1).toUpperCase())
const task = require('./lib/task')
const tasks = require('require-directory')(module, '.', { recurse: false, rename: camelCase })
const bundleName = 'ui'
const buildDir = 'build'
const previewSiteSrcDir = 'preview-site-src'
const previewSiteDestDir = 'public'
const previewSrcDir = 'preview-site-src'
const previewDestDir = 'public'
const srcDir = 'src'
const destDir = `${previewSiteDestDir}/_`
const destDir = `${previewDestDir}/_`
const { reload: livereload } = process.env.LIVERELOAD === 'true' ? require('gulp-connect') : {}
const glob = { cssFiles: `${srcDir}/css/**/*.css`, jsFiles: ['gulpfile.js/**/*.js', `${srcDir}/{helpers,js}/**/*.js`] }
const { remove, lintCss, lintJs, format, build, pack, previewPages, previewServe } = tasks
const { remove, lintCss, lintJs, format, build, pack, previewPages, previewServe } = require('./tasks')
const glob = {
all: [srcDir, previewSrcDir],
css: `${srcDir}/css/**/*.css`,
js: ['gulpfile.js/**/*.js', `${srcDir}/{helpers,js}/**/*.js`]
}
const cleanTask = task({
name: 'clean',
......@@ -25,13 +27,13 @@ const cleanTask = task({
const lintCssTask = task({
name: 'lint:css',
desc: 'Lint the CSS source files using stylelint (standard config)',
call: lintCss(glob.cssFiles),
call: lintCss(glob.css),
})
const lintJsTask = task({
name: 'lint:js',
desc: 'Lint the JavaScript source files using eslint (JavaScript Standard Style)',
call: lintJs(glob.jsFiles),
call: lintJs(glob.js),
})
const lintTask = task({
......@@ -43,7 +45,7 @@ const lintTask = task({
const formatTask = task({
name: 'format',
desc: 'Format the JavaScript source files using prettify (JavaScript Standard Style)',
call: format(glob.jsFiles),
call: format(glob.js),
})
const buildTask = task({
......@@ -71,7 +73,7 @@ const bundleTask = task({
const previewPagesTask = task({
name: 'preview:pages',
call: previewPages(srcDir, destDir, previewSiteSrcDir, previewSiteDestDir, livereload),
call: previewPages(srcDir, destDir, previewSrcDir, previewDestDir, livereload),
})
const previewBuildTask = task({
......@@ -82,11 +84,7 @@ const previewBuildTask = task({
const previewServeTask = task({
name: 'preview:serve',
call: previewServe(previewSiteDestDir, {
port: 5252,
livereload,
watch: { glob: [srcDir, previewSiteSrcDir], call: previewBuildTask },
}),
call: previewServe(previewDestDir, { port: 5252, livereload, watch: { glob: glob.all, call: previewBuildTask } }),
})
const previewTask = task({
......
......@@ -9,7 +9,8 @@ const fs = require('fs-extra')
const imagemin = require('gulp-imagemin')
const merge = require('merge-stream')
const { obj: map } = require('through2')
const path = require('path')
const ospath = require('path')
const path = ospath.posix
const postcss = require('gulp-postcss')
const postcssCalc = require('postcss-calc')
const postcssImport = require('postcss-import')
......@@ -27,9 +28,9 @@ module.exports = (src, dest, preview) => () => {
filter: '**/~typeface-*/files/*',
url: (asset) => {
const relpath = asset.pathname.substr(1)
const abspath = path.resolve('node_modules', relpath)
const basename = path.basename(abspath)
const destpath = path.join(dest, 'font', basename)
const abspath = ospath.resolve('node_modules', relpath)
const basename = ospath.basename(abspath)
const destpath = ospath.join(dest, 'font', basename)
if (!fs.pathExistsSync(destpath)) fs.copySync(abspath, destpath)
return path.join('..', 'font', basename)
},
......
'use strict'
const prettier = require('./lib/gulp-prettier-eslint')
const prettier = require('../lib/gulp-prettier-eslint')
const vfs = require('vinyl-fs')
module.exports = (files) => () =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment