It was actually pretty straight forward to make some additions to the gulpfile to make things happen:
// Build the "dist" folder by running all of the below tasks
gulp.task('build',
gulp.series(clean, gulp.parallel(pages, sass, javascript, images, copy, flowplayer, vendor, _build, chunks, snippets)));
// Build the site, run the server, and watch for file changes
gulp.task('default',
gulp.series('build', server, watch));
// Delete the "dist" folder
// This happens every time a build starts
function clean(done) {
rimraf(PATHS.dist + '/assets/css', done);
rimraf(PATHS.dist + '/assets/img', done);
rimraf(PATHS.dist + '/assets/js', done);
rimraf(PATHS.dist + '/_build', done);
rimraf(PATHS.dist + '/assets/views', done);
}
function chunks() {
let files = [
'src/layouts/**/*',
'src/partials/**/*'
];
return gulp.src(files, {base:'src/'})
.pipe(replace('{{> ', '[[$'))
.pipe(replace('}}', ']]'))
.pipe(gulp.dest(PATHS.dist + '/assets/views'));
}
function snippets() {
let files = [
'src/snippets/**/*',
'src/plugins/**/*'
];
return gulp.src(files, {base:'src/'})
.pipe(gulp.dest(PATHS.dist + '/assets/views'));
}
// Watch for changes to static assets, pages, Sass, and JavaScript
function watch() {
let watch_chunks = [
'src/layouts/**/*',
'src/partials/**/*'
];
let watch_snippets = [
'src/snippets/**/*',
'src/plugins/**/*'
];
gulp.watch(PATHS.assets, copy);
gulp.watch('src/pages/**/*.html').on('all', gulp.series(pages, browser.reload));
gulp.watch('src/{layouts,partials}/**/*.html').on('all', gulp.series(resetPages, pages, browser.reload));
gulp.watch('src/assets/scss/**/*.scss').on('all', sass);
gulp.watch('src/assets/js/**/*.js').on('all', gulp.series(javascript, browser.reload));
gulp.watch('src/assets/img/**/*').on('all', gulp.series(images, browser.reload));
gulp.watch('src/assets/js/vendor/**').on('all', gulp.series(vendor, browser.reload));
gulp.watch('src/_build/**').on('all', gulp.series(_build, browser.reload));
gulp.watch(watch_chunks).on('all', gulp.series(chunks, browser.reload));
gulp.watch(watch_snippets).on('all', gulp.series(snippets, browser.reload));
}
only thing missing here is a regex for replacement ~ the simple string replace works for now but will probably run into issues.
just working on a snippet that will create all the chunks/templates/categories and snippets in modx from the directory structure that gets built in the distribution path.
the last part would be some kind of plugin or watcher that will that will shwack the modx cache when changes are detected.
The one thing I am not sure of at this point is under what conditions does modx save a static file to the database? When it has to rebuild the cache, does it read the static files and update the db?