0

How do I use multiple data files in Nunjucks? — an array of strings does not work for me;

gulp.task('nunjucks', function() {
return gulp.src('src/pages/**/*.+(html|nunjucks)')
    .pipe(data(function() {
      /*DOESN'T WORK*/  return require(['./src/js/variables/media-queries.json', './src/data/data.json'])
    }))
    .pipe(nunjucksRender({
        path: ['src/templates']
    }))
    .pipe(gulp.dest('dist'))
    .pipe(connect.reload());

 });
Scott Simpson
  • 3,832
  • 3
  • 27
  • 35

1 Answers1

3

Using two pipe functions with returns solved this:

.pipe(data(function() {
        return require ('./src/js/variables/media-queries.json');
    }))
.pipe(data(function() {
        return require('./src/data/data.json');
    }))
Scott Simpson
  • 3,832
  • 3
  • 27
  • 35