gulp-nunjucks-html + gulp-data not compiling on watch

六月ゝ 毕业季﹏ 提交于 2019-12-08 21:03:30

It took a while but I found a fix for it. I just replaced the commented out line with the line below it:

 .pipe(data(function(file) {
    //return require('./src/model/' + path.basename(file.path) + '.json');
    return JSON.parse(fs.readFileSync('./src/model/' + path.basename(file.path, '.nunjucks') + '.json'));
 }))

Edit: I also had to add var fs = require('fs') to the top of the gulpfile, it's a node package so no additional dependencies were needed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!