Created
August 19, 2021 08:24
-
-
Save andresdhn/31610e5c4c11e214509b5b079dd0729c to your computer and use it in GitHub Desktop.
Shows a Gulpfile with tasks to preprocess Nunjucks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { src, dest, series, watch } = require('gulp') | |
const del = require('del') | |
const njk = require('gulp-nunjucks-render') | |
const beautify = require('gulp-beautify') | |
function clean() { | |
return del(['dist']) | |
} | |
function html() { | |
return src('src/html/pages/*.+(html|njk)') | |
.pipe( | |
njk({ | |
path: ['src/html'], | |
}) | |
) | |
.pipe(beautify.html({ indent_size: 4, preserve_newlines: false })) | |
.pipe(dest('dist')) | |
} | |
function watchFiles() { | |
watch('src/html/**/*', html) | |
} | |
exports.build = series(clean, html) | |
exports.default = series(clean, html, watchFiles) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment