tschaub / grunt-newer

Configure Grunt tasks to run with newer files only.
https://npmjs.org/package/grunt-newer
MIT License
945 stars 53 forks source link

Include all 'src's per src-dest file mapping if any of the src newer #31

Closed CallMeLaNN closed 10 years ago

CallMeLaNN commented 10 years ago

I am not sure how to title this but in multiple src-dest file mappings, each mapping might have multiple src's, when any of the src is newer, I want all the src's to be included.

I already test this with Grunt Files Object Format and Files Array Format.

This inclusion is useful for task that may compile/concatenate multiple src files like concat, uglify and less.

Consider this:

less: {
    options: {
        paths: [
            'app/bower_components/bootstrap/less'
        ]
    },
    files: {
        'app/styles/bootstrap.css': [
            'app/styles/bootstrap/variables.less',
            'app/styles/bootstrap/bootstrap.less',
            'app/styles/bootstrap/theme.less'
        ],
        'app/styles/main.css': [
            'app/styles/main.less'
        ]
    }
}

If variables.less was modified, newer should include all the 3 files instead of just variables.less so less will compile properly to the dest bootstrap.css.

Currently this is the newer output to the less:

    files: {
        'app/styles/bootstrap.css': [
            'app/styles/bootstrap/variables.less'
        ]
    }

But I expect to have this:

    files: {
        'app/styles/bootstrap.css': [
            'app/styles/bootstrap/variables.less',
            'app/styles/bootstrap/bootstrap.less',
            'app/styles/bootstrap/theme.less'
        ]
    }

I try to use wildcard but it produce the same:

    files: {
        'app/styles/bootstrap.css': [
            'app/styles/bootstrap/*.less'
        ],
        'app/styles/main.css': [
            'app/styles/main.less'
        ]
    }

Personally I see this is must have option unless I use it only for jshint or copy task.

I think if we have this option, we can use this as workaround to other dependencies issue related to @import for less, scss or stylus by adding all the includes into the src's.

tschaub commented 10 years ago

This is exactly the intended behavior when there is a many:1 src:dest mapping (all sources will be included if any is newer). This behavior was introduced to the newer task with #17 and published as grunt-newer@0.6.0. Are you using an earlier version by chance?

I'll try to put together a test with the grunt-contrib-less plugin to see what is up.

CallMeLaNN commented 10 years ago

I am using Yeoman Angular Generator. You are right, I have v0.5.4, I should check if it latest first. It work after I update to the latest one. Thanks.

tschaub commented 10 years ago

The next release of generator-angular should use the latest grunt-newer. Let me know if you are still seeing any issues.