Comments (3)
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.
That causes it to run separately for each image, which is made even worse when quitAfter
is set to true
.
from grunt-imageoptim.
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 .jpg
s (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)
- Enable access for assistive devices issue HOT 9
- Fails when processing very large folders HOT 15
- 3.6hours later.... nothing was written HOT 6
- Running with grunt-newer task HOT 3
- Image optim not installed HOT 3
- prevent generation loss? HOT 3
- Need to make some corrections to README file
- Integration with grunt-newer and similar HOT 2
- Is it possible to gather the binaries from deps? HOT 3
- New version of imageoptim-cli breaks Jpegmini functionality HOT 2
- Imageoptim opening gui HOT 1
- JPEGmini not working - imageoptim-cli v1.11.6 :: grunt-imageoptim v1.4.1 :: Grunt v0.4.5 :: JPEGmini v1.9.0 HOT 1
- ImageAlpha doesn't appear to be running HOT 2
- Problem with Grunt HOT 2
- Only seeing "kb" as output after running grunt task HOT 1
- Output to different destination?
- quitAfter: false not working
- Crashes grunt if no images are found in one or more folders
- Features requested HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-imageoptim.