Closed piotrd closed 9 years ago
I finally ended up with using node.js' fs
module like this:
gulp.task('views', [], function() {
var srcPath = config.app('/views/**/*.jade');
var destPath = config.dist('views/');
var destPathExists = false;
try {
destPathExists = fs.statSync(destPath).isDirectory();
} catch (ex) {
}
return gulp.src(srcPath)
.pipe(newer({dest: destPath, ext: '.html'}))
//filter out unchanged partials, but it only works when watching
.pipe(cached('jade'))
.pipe(gulpif(destPathExists, jadeInheritance({basedir: config.app('/views')})))
//filter out partials (folders and files starting with "_" )
.pipe(filter(function (file) {
return !/\/_/.test(file.path) && !/^_/.test(file.relative);
}))
.pipe(jade())
.on('error', handleErrors)
.pipe(gulpif(config.htmlmin, htmlmin({collapseWhitespace: true})))
.on('error', handleErrors)
.pipe(gulp.dest(destPath));
});
Hi there. I have a project with quite a lot of views (>130 jade files). Analyzing all of them by
jadeInheritance()
is not needed on initial run, since all of them need to be compiled by jade anyway. I was trying to find a way to skipjadeInheritance()
on first build and run it subsequently on the changed files only, but so far I got nowhere.Does anyone have any idea of how to achieve that?
For reference, here is my task: