Comments (3)
I think this would help me, too. I have a task that converts an SVG to several PNGs in a destination folder. This takes some time, so I only really want to run it again when the single src
SVG file has changed. But grunt-newer always runs the SVG-to-PNGs task because it expects to find a file in the dest
directory with the same name as the source SVG file (of course it won't, because there are multiple dest
files with different names and .png instead of .svg for their extensions).
So, I think what we are asking for is:
if dest is a directory:
treat task as if it were a source-files-only task (only check the timestamp(s) of the source file(s))
Does this make sense? Happy to provide further info if you're interested.
[ Note: I'm trying grunt-newer in a different branch to the one I linked to above, which is why it's not in the Gruntfile (yet) ]
from grunt-newer.
@matatk Check out my fork, where I fixed this issue: sevarubbo/grunt-newer. Since it looks like this project is not being supported for quite a long time, I think the only option is to make forks :)
It's quite easy to use, actually. In your package.json
just replace "grunt-newer": "^1.2.0"
with "grunt-newer": "sevarubbo/grunt-newer"
from grunt-newer.
Hi @sevarubbo, and thanks for your reply. I checked out your fork, and it does exactly what you said it does; thanks. However, I now realise this is not actually exactly what I need...
My problem is that when I configure grunt-phantom-rasterize to generate output files in the correct output directory, grunt-newer thinks that the output files are not there, and always re-runs the task. This is the output from grunt -v
Running "newer:rasterize:chrome" (newer) task
Options: cache="/Users/matatk/projects/landmarks/node_modules/grunt-newer/.cache", override=undefined, tolerance=0
Files: src/assemble/landmarks.svg -> ../../cache/landmarks.svg
The problem is that the output files have names like "landmarks-32.png" and "landmarks-48.png" and not just "landmarks.svg". My current files
objects look like this:
files: [{
expand: true,
cwd: srcAssembleDir,
src: 'landmarks.svg',
dest: path.join('..', '..', pngCacheDir)
}]
I did try to reconfigure the files
object in my Gruntfile in order to ensure that grunt-newer sees dest
as a directory:
files: [{
src: path.join(srcAssembleDir, 'landmarks.svg'),
dest: path.join('..', '..', pngCacheDir)
}]
In this case, your fork of grunt-newer behaves perfectly, detecting that dest
is a directory and ignoring it if landmarks.svg has not changed.
Running "newer:rasterize:chrome" (newer) task
Options: cache="/Users/matatk/projects/landmarks/node_modules/grunt-newer/.cache", override=undefined, tolerance=0
Files: src/assemble/landmarks.svg -> ../../cache
However, when I set up the files
object in this way, grunt-phantom-rasterize always outputs the PNG files in the root directory of the repo, rather than the "cache" directory.
I can think of a hacky solution: simply move the PNG files to the cache directory when they have been generated, but this feels totally wrong.
However, this is now somewhat off topic for grunt-newer I think! So I will try to figure it out. Thanks to @tschaub for writing this in the first place and to you @sevarubbo for your updates.
Update: actually I just re-checked and grunt-newer doesn't work if I use ../../cache
as the dest
path, as it appears that grunt-newer is treating dest
as relative to Gruntfile.js
, but grunt-phantom-rasterize is treating dest
as relative to src
. My head hurts! :-) Suspect I'm making a n00b error here; will keep researching...
from grunt-newer.
Related Issues (20)
- Naming convention
- newer not updating only the changed file
- Save timestamps for individual files & re-run the task on change HOT 2
- How to configure the task to check just the saved file? HOT 1
- If the task fails, newer-postrun:... never gets called HOT 4
- Has anyone developed a workflow using this with clean? HOT 3
- Option to force running on all files
- Simply doesn't work with copy task HOT 10
- Doesn't work with grunt-cwebp
- Does not work with grunt-contrib-copy due to the timestamp precision disagreement HOT 17
- error: The "newer" prefix is not supported for aliases HOT 1
- override function isn't load from config file
- Add option to invalidate cache when Gruntfile.js changes HOT 2
- Assemble.io HOT 2
- Is this support task that is not load from npm, but from grunt.task.registerTask(taskName, description, taskFunction)? HOT 1
- arls
- Reference files not compiled when using grunt-ts
- str.replace is not a function HOT 2
- Add 'dest' to 'detail' parameter of 'override' function
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-newer.