Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image task not copying some images over to dist? #579

Closed
bluematter opened this issue Dec 20, 2014 · 19 comments
Closed

Image task not copying some images over to dist? #579

bluematter opened this issue Dec 20, 2014 · 19 comments
Labels

Comments

@bluematter
Copy link

I have been struggling with gulp-imagemin for the past few days, one it will not compress the images, I am basing that off the images being the same file size and page speed insights telling me to compress them, this is not a big deal as I don't use many images and can manually compress them, just thought I would mention this.

The thing that gets me is why certain images are not being copied over into the dist build. This has happened to me on numerous occasions over the past few days. I tried clearing the gulp-cache

gulp.task('clear', function (done) {
  return $.cache.clearAll(done);
});

I am not sure what else I can add, I doubt this is enough to help troubleshoot, but has anyone else experienced this, perhaps I am doing something wrong?

@bluematter bluematter changed the title Image task not copying images over to dist? Image task not copying some images over to dist? Dec 20, 2014
@bluematter
Copy link
Author

After removing $.cache it seems to have worked, wish I tried that before posting.

this

.pipe($.cache($.imagemin({
  progressive: true,
  interlaced: true
})))

to

.pipe($.imagemin({
  progressive: true,
  interlaced: true
}))

@addyosmani
Copy link
Contributor

Thanks for posting back about the caching issues you ran into. You shouldn't have to disable $.cache in this way, but we'll investigate and see if we can repro.

@ithinkihaveacat
Copy link
Contributor

@bluematter Long shot, but are all your images in the in the app/images directory? Images in other directories will be served by gulp serve, but they won't become part of the static dist build. (Something like this might help make them work; this doesn't explain the interaction with caching though…)

@addyosmani
Copy link
Contributor

I haven't been able to reproduce this issue. Is anyone else running into this issue with gulp-cache? I've been reading up on jgable/gulp-cache#16 but that issue is closed.

@bluematter
Copy link
Author

Sorry guys, totally forgot about this, if can remember correctly, when I initially started having this issue all the images were indeed in the app/images directory. Then I moved them into a sub-dir, I may have to go back and recreate the issue myself.

I went ahead and manually compressed my images with compressor.io. That said I avoid using many images so I haven't really focused on this issue, I just left the task without the $.cache plugin.

All I remember is at the time it was a pain, I will see what happens when I add $.cache and report back with as much details as possible!

@akullpp
Copy link

akullpp commented Jan 12, 2015

Encountered the same issue in combination with Jenkins, same setup as described above.

@webwelten
Copy link

Same problem here.
Have the images in app/images as well and not using $.cache makes it work.

@webwelten
Copy link

What helped in my case was clearing the cache. Once I did that I've had no more problems (for now). Does this also help someone else?

Maybe gulp-newer is an alternative for this task?

@hugohcn
Copy link

hugohcn commented Feb 22, 2015

Hey Guys,

I have the same problem here. Looking for a solution, I tried this code and it worked:

// Optimize Images
gulp.task('images', function () {
  return gulp.src('app/images/**/*.{gif,jpg,png,svg}')
    .pipe($.cache($.imagemin({
      progressive: true,
      interlaced: true,
      pngquant: true
    })))
    .pipe(gulp.dest('dist/images'))
    .pipe($.size({title: 'images'}));
});

pavgup added a commit to pavgup/web-starter-kit that referenced this issue Feb 22, 2015
This fixed google#579.  Somewhat recently, the gulp-cache repository made some changes that made sending files not easily managed by gulp-cache a much simpler pill to swallow.  That's definitely changing (they're fixing problems, to be clear) and short of a simple gulp.src nodir+follow option, using the included gulp-if plugin to drop out of the file stream the base directories makes the gulp file work super smoothly.  Hope it helps!
pavgup added a commit to pavgup/web-starter-kit that referenced this issue Feb 22, 2015
… gulp.src base directories for image glob

Take a gander at google#636 for a few more details. This fix might work in a lot of branches, frankly, but the material-sprint branch is where I first ran into issues.  Hopefully it helps!  (And this fixes google#579.)
@pavgup
Copy link

pavgup commented Feb 23, 2015

Hola. Looks like the gulp.src function was sending along base directories (e.g., app/images/icon) and this was causing a freshly tightened gulp-cache to choke on generating a key for a file that it could not understand. Using gulp-if and it's direct relationship with gulp-match, you can comfortably drop out the base directories from the image optimization pipeline before you run into problems. This is a bit of an annoying problem (globs suck, the gulp-cache plugin needs friends, and it looks like a lot of people hack their way around this problem), but I bet this kind of pattern feels right -- you're checking to see if you're reviewing a file before you start trying to process a file. Poke me with questions! Hope this helps!

@hugohcn
Copy link

hugohcn commented Feb 23, 2015

@PavanGupta nice! thks.

JosefJezek added a commit to StartPolymer/polymer-starter-kit-old that referenced this issue Feb 23, 2015
@pavgup
Copy link

pavgup commented Feb 23, 2015

:), happy to help!

@shinnn
Copy link
Contributor

shinnn commented Feb 24, 2015

Fixed in jgable/gulp-cache#43.

@shinnn
Copy link
Contributor

shinnn commented Feb 28, 2015

@pavgup You can close both this and #636.

@pavgup
Copy link

pavgup commented Mar 1, 2015

@shinnn you guys are awesome! pull requests closed!

JosefJezek added a commit to StartPolymer/polymer-starter-kit-old that referenced this issue Mar 2, 2015
@neilmonroe
Copy link

Thanks for fixing this! I was still having the issue even after upgrading all of the node dependencies. The key was what @webwelten suggested. You have to clear the cache to get rid of bad entries or else you will still get the missing files in your dist build.

@stevemao
Copy link
Contributor

This can also be closed :)

@nicolasgarnier
Copy link
Contributor

Closing! :D

@NicolasRannou
Copy link

Doesn't seem to work after pulling master today...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.