2018-11-20 10:26:26 -05:00
|
|
|
const { src, dest, series, parallel, watch } = require('gulp'),
|
2020-11-02 09:19:40 -05:00
|
|
|
del = require('del'),
|
2018-11-20 10:26:26 -05:00
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
2020-11-02 09:19:40 -05:00
|
|
|
// Cleans the build folder for the dev lifecycle
|
|
|
|
function clean(cb) {
|
|
|
|
del([paths.dist + '**'], cb());
|
|
|
|
}
|
|
|
|
|
2018-11-20 10:26:26 -05:00
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
|
2020-11-02 09:19:40 -05:00
|
|
|
// cleans the build folder for the dev lifecycle
|
|
|
|
function cleanDev(cb) {
|
|
|
|
del([paths.web + '**'], cb());
|
|
|
|
}
|
|
|
|
|
2018-11-20 10:26:26 -05:00
|
|
|
// Serve sample document and reload for changes
|
|
|
|
function connect(cb) {
|
|
|
|
gulpConnect.server({
|
|
|
|
root: paths.web,
|
|
|
|
livereload: true
|
|
|
|
});
|
|
|
|
cb();
|
|
|
|
}
|
|
|
|
|
2020-11-02 09:19:40 -05:00
|
|
|
const build = series(clean, sass, copyResource);
|
2018-11-20 10:26:26 -05:00
|
|
|
const update = series(build, copyDist, render);
|
|
|
|
exports.default = build;
|
2020-11-02 09:19:40 -05:00
|
|
|
exports.dev = series(cleanDev, update, parallel(connect, watchFiles));
|