Giter Club home page Giter Club logo

Comments (3)

JamieMason avatar JamieMason commented on May 23, 2024

Hi @curtisblackwell,
The problem is that the 'assets/img/**' pattern will match directories within that directory. Although files within assets/img/cache have been ignored, the folder itself hasn't.

Of course, this is counter-intuitive but unfortunately the way things work until ImageOptim-CLI 2.0 is released.

You should be able to work around this with the following;

imageoptim: {
  build: {
    files: [{
      expand: true,
      cwd:    'dist',
      src: [
        'assets/img/**/*.{jpg,jpeg,png,gif}',
        '!assets/img/cache/*.{jpg,jpeg,png,gif}'
      ]
    }]
  }
}

More info in Running grunt-imageoptim with grunt-newer task.

Thanks.

from grunt-imageoptim.

curtisblackwell avatar curtisblackwell commented on May 23, 2024

That causes it to run separately for each image, which is made even worse when quitAfter is set to true.

from grunt-imageoptim.

curtisblackwell avatar curtisblackwell commented on May 23, 2024

I made sure to not copy any of the cached files and that took care of that problem, but I've still got an issue with images being run through multiple times. Here's a simplified version of what I'm working with:

imageoptim: {
  build: {
    files: [{
      expand: true,
      cwd:    'dist',
      src: [
        'assets/img/**',
        'apple-touch-icon*',
        'favicon*',
        'mstile*'
      ]
    }],

    options: {
      jpegMini:   false,
      imageAlpha: true
    }
  }
}

This hits all the right images, but like you said, it hits each dir, then each file in each dir. This is easily fixed by using something like assets/img/**/*.{jpg,jpeg,png,gif} as you mentioned, but it runs separately for each image.

Is that the intended behavior? It's not a big deal here when using only ImageAlpha, but I have a separate task for .jpgs (to prevent all the "skipped this file because it's not a valid format" warnings). jpegMini isn't nearly as fast and has to take over the computer.


I tried seeing if this is a misunderstanding of how Grunt's dynamic files object works, but the other plugins I'm using aren't as verbose in their output, and it's not apparent just watching the screen.

However, what I think would make the most sense is to generate a list of files to process (from the files object) per task, then process them all in one sweep.

P.S.
As things run now, the quitAfter option is practically unusable, which is unfortunate.

from grunt-imageoptim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.