Skip to content

Instantly share code, notes, and snippets.

@psyrendust
Created November 9, 2015 17:47
Show Gist options
  • Save psyrendust/37844bd8e0f2dea0c8ea to your computer and use it in GitHub Desktop.
Save psyrendust/37844bd8e0f2dea0c8ea to your computer and use it in GitHub Desktop.
gulp build for esdoc
// location: gulp/tasks/docs.js
const gulp = require('gulp');
const esdoc = require('gulp-esdoc');
const newer = require('gulp-newer');
const plumber = require('gulp-plumber');
const esdocJSON = require('../../esdoc.json');
const logger = require('../util/logger');
const esdocOptions = Object.assign({}, esdocJSON, {
destination: paths.docs,
source: null,
});
gulp.task('docs', () => {
return gulp.src(paths.docsEntry)
.pipe(plumber())
.pipe(newer(paths.docs))
.pipe(esdoc(esdocOptions));
});
gulp.task('docs:watch', () => {
gulp.watch([paths.scripts, paths.manual, 'README.md'], ['docs']).on('change', evt => logger('Watching', evt, 'docs'));
});
{
"source": "./src/magellan",
"destination": "./dist/docs",
"access": ["public", "protected", "private"],
"debug": false,
"index": "./README.md",
"package": "./package.json",
"title": "Magellan",
"plugins": [
{
"name": "esdoc-es7-plugin"
},
{
"name": "esdoc-importpath-plugin",
"option": {
"replaces": [
{
"from": "^magellan/",
"to": ""
}
]
}
}
],
"manual": {
"overview": ["./manual/overview.md"],
"installation": ["./manual/installation.md"],
"usage": ["./manual/usage.md"],
"example": ["./manual/example.md"],
"faq": ["./manual/faq.md"],
"changelog": ["CHANGELOG.md"]
}
}
const gulp = require('gulp');
const path = require('path');
const requireDir = require('require-dir');
// Load in package.json
const pkg = require('./package.json');
global.paths = {
src: './src',
out: './dist',
docs: './docs',
test: './test',
manual: './manual/*.md',
vendor: pkg.vendor.map(item => path.join('node_modules', item)),
get docsEntry() { return `${this.src}/magellan`; },
get jsEntry() { return `${this.src}/magellan/index`; },
get scripts() { return `${this.src}/magellan/**/*.js`; },
get sass() { return `${this.src}/scss/**/*.scss`; },
get sassEntry() { return `${this.src}/scss/index.scss`; },
get vendorOut() { return `${this.out}/vendor`; },
};
// Load in all modular gulp tasks
requireDir('./gulp/tasks', { recurse: true });
gulp.task('default', ['lint', 'build']);
// location: gulp/util/logger.js
const gutil = require('gulp-util');
const path = require('path');
module.exports = function logger(prefix, evt, task) {
gutil.log(`${prefix} '${gutil.colors.cyan(`file ${evt.type}`)}' ${path.relative(path.dirname(__dirname), evt.path)} ${gutil.colors.magenta(`running '${task}'...`)}`);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment