gulp-htmlbuild
gulp-htmlbuild copied to clipboard
Cant chain to the htmlbuild task
I have below,
My issue is that the task HiThere NEVERS runs due to 'build' not returning. can you advise
gulp.task('build', function() {
return gulp.src(['./index.html'])
.pipe(
htmlbuild({
// build js with preprocessor
js: htmlbuild.preprocess.js(function(block) {
block.pipe(gulpSrc())
// .pipe( print () )
.pipe(jsBuild);
block.end('js/concat.js');
}),
// build css with preprocessor
css: htmlbuild.preprocess.css(function(block) {
block.pipe(gulpSrc())
.pipe(cssBuild);
block.end('css/concat.css');
}),
// build css with preprocessor
less: htmlbuild.preprocess.css(function(block) {
block.pipe(gulpSrc())
.pipe(lessBuild);
block.end('less/concat.less');
}),
// remove blocks with this target
remove: function(block) {
block.end();
},
// add a template with this target
template: function(block) {
es.readArray([
'<!--',
' processed by htmlbuild (' + block.args[0] + ')',
'-->'
].map(function(str) {
return block.indent + str;
})).pipe(block);
}
}) // htmlbuild
)
.pipe(gulp.dest('./dist'))
});
gulp.task('HiThere', ['build'], function() {
return gulp.src('./dist/js/concat.js')
.pipe(uglify({
mangle: false
}))
.pipe(gulp.dest('dist/js'))
});
You don't need the HiThere
task. It should go right in the htmlBuild
// ...
htmlbuild({
// build js with preprocessor
js: htmlbuild.preprocess.js(function(block) {
block.pipe(gulpSrc())
.pipe(jsBuild)
.pipe(uglify({
mangle: false
}));
block.end('dist/js/concat.js');
}),
// ...
if you want to only minify on certain environments do it like this.
but i do want other tasks to run after the 'build' and something appears to be wrong with the build task not ending to allow HiThere to trigger.