grunt-newer not working with grunt-sass

660 Views Asked by At

I am trying to use grunt-newer to pick up changes to my sass partials to then run the grunt-sass task. For some reason, it doesn't seem to register any updates. Argh!

Example directory structure:

sass
    - components
        _breadcrumb.scss
    - helpers
        _variables.scss
    main.scss

Sass config:

files: [{
    expand: true,
    cwd: 'static/sass',
    src: ['*.scss'],
    // src: ['**/*.scss'],
    dest: 'static/styles',
    ext: '.css'
}]

main.scss contains the @imports used to read in the partials.

Running grunt newer:sass will look for changes to main.scss. Updating the globbing rule to use **/*.scss doesn't pick up any changes at all in any file.

It feels like a globbing issue but I just can't crack it.

Any help would be appreciated.

1

There are 1 best solutions below

0
On

See grunt-newer page, specifically the section 'overwrite' at the end of the page. That's the way to go.

grunt.config('newer', {
  options: {
    override: function (detail, include) {
      if (detail.task == 'sass') {
        if (detail.path.match('^sass/includes/')) {
          include(true);
        }
        else {
          include(false);
        }
      }
      else {
        include(false);
      }
    }
  }
});

(don't forget to adapt and expand ^sass/includes/ to your filetree)

I am not yet 100% sure if this scans ALL files in that folder EVERY time no matter if they are "newer" or not, though...