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

There should be an option to force newer to work in "src only mode" #37

Open voltidev opened 10 years ago

voltidev commented 10 years ago

Even if a task specifies dest files, there should be a way to force newer to work in "src only mode".

What if you clean the dest directory within the building process. So newer will have no chance to ignore old files.

For example:

grunt.initConfig
  clean:
    build: 'project/build'

  imagemin:
    build:
      files: [{
        expand: true
        cwd: 'project/src/images'
        src: '**/*'
        dest: 'project/build/images'
      }]

grunt.registerTask('imagemin_', ['newer:imagemin'])

grunt.registerTask('build', ['clean', 'imagemin_'])
mattkime commented 10 years ago

I'm a bit confused. i believe that newer looks at src files and compares them to that last build time.

can you restate the problem you're facing?

blowsie commented 9 years ago

I agree with @mattkime , I cant see an issue here, and believe this is the expected behaviour

ghost commented 8 years ago

+1 .... Trying to operate on SCSS files, but it's only considering the bundle files, and not any partials because they would NEVER exist in the destination as per how SASS compilers work, they ignore partials (e.x.: files starting with an underscore).

It seems that a default of current logic is fine, but could be overridden by a forceSrcEval boolean in options. This would then utilize the source file for comparing against the destination file.

Example:

[SRC]
assets/
     css/
        main.bundle.scss
        _partial_included_in_main.scss

[DEST]
dist/
     /assets
          /css
             /main.bundle.css

As you can see, on initial compile of starting the grunt task, the main bundle is compiled as expected, and all partials are left in the source (and embedded within the main bundle). As stated above, since the partials never exist in the destination folder there's no way to validly compare.

The only caveat on this is that processing new files will iterate over all watched files and evaluated through override or the filters.

matatk commented 8 years ago

I have encountered the same problem. I am using a grunt task to convert an SVG into various different-sized PNGs. I would like newer to only look at the last-modified date of the SVG file, which is the 'src' file in my grunt task. The task I am using specifies a 'dest' directory, where the PNGs are output, but newer thinks that the destination file is going to be an SVG file with the same name as the 'src' file, just in the 'dest' directory. However, the output of the task is actually lots of different PNG files in the 'dest' directory, none of which have the same name as the 'src' file.

There are two situations I can think of that are affected, and imagine they could be quite common:

Essentially the underlying problem is:

Therefore: if we had an option to force newer to look at the last-modified date of the 'src' file only, ignoring any 'dest' file/files, then newer could be used with any grunt task that generates temporary files, or tasks that generate many output files for one 'src' file.

P.S. Thanks for this plugin; when this issue is resolved it's going to save me (and others I hope) a lot of time :-).