Janpot / gulp-htmlbuild

Extract content from html documents and replace by build result
https://www.npmjs.org/package/gulp-htmlbuild
MIT License
23 stars 5 forks source link

Cant chain to the htmlbuild task #12

Open geetee24 opened 7 years ago

geetee24 commented 7 years ago

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'))
});
Janpot commented 7 years ago

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.

geetee24 commented 7 years ago

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.