Dragory / gulp-hash

A gulp plugin for cachebusting files by adding a hash to their name and/or content.
MIT License
69 stars 24 forks source link

options.append doesn't seem to be working anymore #19

Closed gkpo closed 7 years ago

gkpo commented 7 years ago

Just updated my npm packages. The problem now is that the assets.json file just gets overwritten each time hash.manifest is called. Here's my code:

// Concatenate all js files into one file
gulp.task('concat-js', function(){  
  var vendorScripts = gulp.src(dest(paths.scripts.vendor));
  var appScripts = gulp.src(dest(convertCoffeeFileName(paths.scripts.coffee)));
  var appTemplates = gulp.src(dest('templates.js'));

  return series(vendorScripts, appScripts, appTemplates)
  .pipe(uglify())
  .pipe(concat(paths.scripts.outputFileName))
  .pipe(hash())
  .pipe(gulp.dest(paths.dest)) // write concatenated file
  .pipe(hash.manifest(paths.assetsManifest))
  .pipe(gulp.dest(paths.dest)); // write assets manifest file
});

// Concatenate all css files into one file
gulp.task('concat-css', function(){    
  var vendorStyles = gulp.src(dest(paths.styles.app.vendor));
  var fontsStyles = gulp.src(dest(paths.styles.app.fonts));
  var appStyles = gulp.src(dest(convertLessFileName(paths.styles.app.less.main)));

  return series(vendorStyles, fontsStyles, appStyles)
  .pipe(cleanCss({keepSpecialComments: 0}))
  .pipe(concat(paths.styles.app.outputFileName))
  .pipe(hash(hashOptions))
  .pipe(gulp.dest(paths.dest)) // write concatenated file
  .pipe(hash.manifest(paths.assetsManifest))
  .pipe(gulp.dest(paths.dest)); // write assets manifest file
});

This code results in assets.json looking like so: the last call overrides the first call. The file should contain 2 lines but only has one:

{"styles.css":"styles.407f6229.css"}

I tried adding {append: true} as the 2nd parameter even thought it's true by default. Doesn't help. am I doing something wrong? Thanks

Dragory commented 7 years ago

Hey! Thanks for the report, it seems among the recent changes append was erroneously set to false by default. I have published a fix for this (version 4.1.1).

I wasn't, however, able to recreate the problem with {append: true} (while having it false by default, before the new version) - maybe you accidentally added it as a parameter to pipe()? In any case, try updating to 4.1.1 and report back it it doesn't work.

gkpo commented 7 years ago

You're right, updating to 4.1.1 fixed the issue. Thanks : )

Dragory commented 7 years ago

Good to know! Have a good one.