grunt-newer icon indicating copy to clipboard operation
grunt-newer copied to clipboard

Ability to not overwrite config of a task

Open kfiku opened this issue 12 years ago • 7 comments

I Propose to add the ability to not overwrite config of a task. There are a tasks like grunticon witch need original config (with all files) to work right - so grunt-newer will run full task if any file will change. To ignore changing config (line 120) need to add in never task options changeConfig: false. You can specify changeConfig to all task, or to single taks:

newer: {
    options: {
        cache: 'app/cache/grunt',
        changeConfig: false
    }
}

or

newer: {
    options: {
        cache: 'app/cache/grunt',
        grunticon: {
            changeConfig: false
        }
    }
}

kfiku avatar Mar 03 '14 12:03 kfiku

The way this is implemented, it looks like it would have the same effect as not prefixing your grunticon task with newer.

The point of overwriting the config is so a task works with a limited set of files (only those that are newer). If you don't modify the config, the newer task will have no effect.

Can you give an example of your grunticon config and describe how you expect things to behave with regard to modifying files?

tschaub avatar Mar 03 '14 22:03 tschaub

I known what is newer :) it's grate think, but in grunticon situation I need to run grunticon only if any source file change, but full task, with all files.

grunticon is task that manage svg/png files for all devices and generating png/svs/css for it. So you can't go only with, for example, 3 of 10 images, becouse you end up with css classes for 3 images.

In grunticon like in other css sprite generators images for it is not changing very often, but you need this task in build process. It's also take a while to process (in my situation is 43sec.). So if we can make it faster - check if any file is chcange - it will be very cool.

Example grunticon task

grunticon: {
    options: {
        pngfolder: '',
        template: '<%= conf.app %>/images/sprite/template.hbs'
    },
    icons: {
        files: [{
            expand: true,
            cwd: '<%= conf.app %>/images/sprite',
            src: ['*.svg', '*.png'],
            ext: '.png',
            dest: '<%= conf.app %>/images/generated'
        }],
    }
};

kfiku avatar Mar 04 '14 06:03 kfiku

+1 @kfiku

I'm interested in this functionality as well. I'm taking a look at your patch to see if it solves my problem as well.

thanks!

mattkime avatar Apr 23 '14 14:04 mattkime

@mattkime we are blocked by @tschaub. I think @tschaub don't see a lot of use cases where this feature can be grate. Also grate can be somethink like hybrid with grunt-never and https://github.com/rse/grunt-newer-explicit

kfiku avatar Apr 23 '14 19:04 kfiku

If newer is used in front of a task with a many:1 source:dest file mapping, the task will be run with all source files if any one of them has changed. This sounds like the behavior you want with the grunticon task.

However, with the above configuration, because expand is true in the files config, this looks like a 1:1 src:dest mapping to Grunt (for each source file, one dest file will be generated). It looks like the grunticon task is a special case that doesn't generate 1 dest file for each source file or 1 dest file for many source files. Instead it generates a few dest files for many source files.

Previously (@v0.5.4) there was an any-newer task that would handle cases like this (including all source files if any one of them was newer than a dest file). I'd be curious to hear if using the any-newer task (in the 0.5.4 release) works for you.

tschaub avatar Apr 28 '14 05:04 tschaub

@tschaub I see you still don't understand how grunticon works and how my commit allow newer works with it. Grunticon must be run with all files because it generates ont only one file from many and not many to many. You specify folder where you have svg|png|jpg... files that you want to mage sprite from, next it generate: 3 css files (3 options), png fallbacks for older browsers.

So again:

  • you need all files (other way you get not all file in sprite)
  • you don't have many to many
  • you don't have one to meny
  • you need to check if any file was change, if so run it with fill config, other way don't run.

You say: The way this is implemented, it looks like it would have the same effect as not prefixing your grunticon task with newer But no, svg sprite source files don't change very often, but we need grunticon in build taks and it can be very long (10-50s.). This update will speed think up

kfiku avatar Apr 30 '14 19:04 kfiku

I believe the options.override feature solves this general problem. move to close this pr but i wanted to give @kfiku a heads up

mattkime avatar Mar 13 '15 21:03 mattkime