Skip to content

Instantly share code, notes, and snippets.

@andresdhn
Created August 19, 2021 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andresdhn/31610e5c4c11e214509b5b079dd0729c to your computer and use it in GitHub Desktop.
Save andresdhn/31610e5c4c11e214509b5b079dd0729c to your computer and use it in GitHub Desktop.
Shows a Gulpfile with tasks to preprocess Nunjucks
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