diff options
author | Dan Allen <dan@opendevise.com> | 2018-12-30 03:55:39 -0700 |
---|---|---|
committer | Dan Allen <dan@opendevise.com> | 2018-12-30 03:58:39 -0700 |
commit | 715626c6433878824f36d4b57089b1cd14578b61 (patch) | |
tree | 66ba98eb4433bfb9f008ba2b20c198971cb5f1ae | |
parent | 7367f6c184fdf7910ffc118b12189465f0894a19 (diff) | |
download | alpine-antora-theme-715626c6433878824f36d4b57089b1cd14578b61.tar.bz2 alpine-antora-theme-715626c6433878824f36d4b57089b1cd14578b61.tar.xz |
consolidate Gulp build
- move task require to gulpfile.js/tasks/index.js
- abbreviate variable names
- use ospath where appropriate
-rw-r--r-- | README.adoc | 4 | ||||
-rw-r--r-- | gulpfile.js/index.js | 30 | ||||
-rw-r--r-- | gulpfile.js/tasks/build.js (renamed from gulpfile.js/build.js) | 9 | ||||
-rw-r--r-- | gulpfile.js/tasks/format.js (renamed from gulpfile.js/format.js) | 2 | ||||
-rw-r--r-- | gulpfile.js/tasks/lint-css.js (renamed from gulpfile.js/lint-css.js) | 0 | ||||
-rw-r--r-- | gulpfile.js/tasks/lint-js.js (renamed from gulpfile.js/lint-js.js) | 0 | ||||
-rw-r--r-- | gulpfile.js/tasks/pack.js (renamed from gulpfile.js/pack.js) | 0 | ||||
-rw-r--r-- | gulpfile.js/tasks/preview-pages.js (renamed from gulpfile.js/preview-pages.js) | 0 | ||||
-rw-r--r-- | gulpfile.js/tasks/preview-serve.js (renamed from gulpfile.js/preview-serve.js) | 0 | ||||
-rw-r--r-- | gulpfile.js/tasks/remove.js (renamed from gulpfile.js/remove.js) | 0 |
10 files changed, 24 insertions, 21 deletions
diff --git a/README.adoc b/README.adoc index 2e522d9..a4218b7 100644 --- a/README.adoc +++ b/README.adoc @@ -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. diff --git a/gulpfile.js/index.js b/gulpfile.js/index.js index 2adc946..64c4795 100644 --- a/gulpfile.js/index.js +++ b/gulpfile.js/index.js @@ -1,20 +1,22 @@ '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({ diff --git a/gulpfile.js/build.js b/gulpfile.js/tasks/build.js index c12f332..a2997e9 100644 --- a/gulpfile.js/build.js +++ b/gulpfile.js/tasks/build.js @@ -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) }, diff --git a/gulpfile.js/format.js b/gulpfile.js/tasks/format.js index c95d506..2d50496 100644 --- a/gulpfile.js/format.js +++ b/gulpfile.js/tasks/format.js @@ -1,6 +1,6 @@ 'use strict' -const prettier = require('./lib/gulp-prettier-eslint') +const prettier = require('../lib/gulp-prettier-eslint') const vfs = require('vinyl-fs') module.exports = (files) => () => diff --git a/gulpfile.js/lint-css.js b/gulpfile.js/tasks/lint-css.js index d684014..d684014 100644 --- a/gulpfile.js/lint-css.js +++ b/gulpfile.js/tasks/lint-css.js diff --git a/gulpfile.js/lint-js.js b/gulpfile.js/tasks/lint-js.js index ef4f3c9..ef4f3c9 100644 --- a/gulpfile.js/lint-js.js +++ b/gulpfile.js/tasks/lint-js.js diff --git a/gulpfile.js/pack.js b/gulpfile.js/tasks/pack.js index 7c9d3ae..7c9d3ae 100644 --- a/gulpfile.js/pack.js +++ b/gulpfile.js/tasks/pack.js diff --git a/gulpfile.js/preview-pages.js b/gulpfile.js/tasks/preview-pages.js index 9e704c2..9e704c2 100644 --- a/gulpfile.js/preview-pages.js +++ b/gulpfile.js/tasks/preview-pages.js diff --git a/gulpfile.js/preview-serve.js b/gulpfile.js/tasks/preview-serve.js index 8ae70cf..8ae70cf 100644 --- a/gulpfile.js/preview-serve.js +++ b/gulpfile.js/tasks/preview-serve.js diff --git a/gulpfile.js/remove.js b/gulpfile.js/tasks/remove.js index 3f71eec..3f71eec 100644 --- a/gulpfile.js/remove.js +++ b/gulpfile.js/tasks/remove.js |