2018-11-20 10:26:26 -05:00
|
|
|
const { src, dest, series, parallel, watch } = require('gulp'),
|
|
|
|
gulpSass = require('gulp-sass'),
|
2020-10-07 09:17:26 -04:00
|
|
|
asciidoctor = require('@asciidoctor/gulp-asciidoctor'),
|
2018-11-20 10:26:26 -05:00
|
|
|
gulpConnect = require('gulp-connect');
|
|
|
|
|
|
|
|
const paths = {
|
|
|
|
sass: 'src/main/sass/**/*.scss',
|
|
|
|
resources: 'src/main/resources/**',
|
|
|
|
dist: 'build/dist/',
|
|
|
|
web: 'build/web/'
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Building the theme
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Compile SASS files to build/dist/css/
|
|
|
|
function sass() {
|
|
|
|
return src(paths.sass)
|
|
|
|
.pipe(gulpSass({outputStyle: 'compressed'}))
|
|
|
|
.pipe(dest(paths.dist + "css"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy static reosurces to build/dist/
|
|
|
|
function copyResource() {
|
|
|
|
return src(paths.resources)
|
|
|
|
.pipe(dest(paths.dist));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Developer tools
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Copy built theme to static web folder
|
|
|
|
function copyDist() {
|
|
|
|
return src(paths.dist + '**')
|
|
|
|
.pipe(dest(paths.web));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Render test Asciidoctor document
|
|
|
|
function render() {
|
|
|
|
return src('src/test/resources/index.adoc')
|
|
|
|
.pipe(asciidoctor({
|
|
|
|
safe: 'unsafe',
|
|
|
|
doctype: 'book',
|
|
|
|
attributes: [
|
|
|
|
'icons=font',
|
|
|
|
'idprefix',
|
|
|
|
'idseparator=-',
|
|
|
|
'docinfo',
|
|
|
|
'sectanchors',
|
|
|
|
'sectnums',
|
|
|
|
'source-highlighter=highlight.js',
|
2018-11-21 11:42:57 -05:00
|
|
|
'highlightjsdir=js/highlight',
|
2020-10-07 10:17:48 -04:00
|
|
|
'highlightjs-theme=github',
|
2018-11-20 10:26:26 -05:00
|
|
|
'stylesdir=css',
|
|
|
|
'stylesheet=spring.css',
|
|
|
|
'docinfo=shared',
|
|
|
|
'linkcss',
|
|
|
|
'docinfodir='.concat(process.cwd(), "/", paths.dist)
|
|
|
|
]
|
|
|
|
}))
|
|
|
|
.pipe(dest(paths.web))
|
|
|
|
.pipe(gulpConnect.reload());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Watch files modified in src/** and rebuild theme + sample document
|
|
|
|
function watchFiles(cb) {
|
|
|
|
watch('src/**', update);
|
|
|
|
cb();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Serve sample document and reload for changes
|
|
|
|
function connect(cb) {
|
|
|
|
gulpConnect.server({
|
|
|
|
root: paths.web,
|
|
|
|
livereload: true
|
|
|
|
});
|
|
|
|
cb();
|
|
|
|
}
|
|
|
|
|
|
|
|
const build = series(sass, copyResource);
|
|
|
|
const update = series(build, copyDist, render);
|
|
|
|
exports.default = build;
|
|
|
|
exports.dev = series(update, parallel(connect, watchFiles));
|