Answer the question
In order to leave comments, you need to log in
How to exclude files from stream depending on path?
Good afternoon. I ran into a problem with ikludes in nunjucks.
There is a project structure like this:
- build
- index.html
- src
- blocks
- block1
- block1.njk
- block2
- block2.njk
- index.njk
// html.
const htmlhint = require('gulp-htmlhint');
const prettyHtml = require('gulp-pretty-html'); // Добавляет индентацию.
const nunjucks = require('gulp-nunjucks-render');
const nunjucksInheritance = require('gulp-nunjucks-inheritance');
function html() {
return src('src/**/*.{html,njk}', { base: 'src', since: lastRun('html') })
// Nunjucks
.pipe(nunjucksInheritance({ base: 'src' })) // Ищем изменения в зависимостях
.pipe(nunjucks({ path: 'src' })) // Компилируем в HTML
// Добавляет индентацию для заинклюженных блоков.
.pipe(prettyHtml({ indent_size: 2 }))
// HTML-валидатор.
.pipe(htmlhint('.htmlhintrc'))
.pipe(htmlhint.reporter())
// Манифест.
// Если флаг --dist без --norev.
.pipe(gulpif(dist, gulpif(distRev, revReplace({
manifest: src('manifest/manifest.json', { allowEmpty: true }),
}))))
// Выгрузка.
.pipe(dest(buildHtml))
// browserSync.
.pipe(gulpif(!dist, browserSync.stream())); // Если нет флага --dist.
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question