0
votes

I have this grunt task:

watch: {
  files: ['resources/assets/sass/*.scss'],
  tasks: ['csscomb:sortAll', 'sass:theme', 'sass:mail']
},
csscomb: {
  options: {
    config: 'csscomb.json'
  },
  sortAll: {
    expand: true,
    cwd: '.',
    src: ['resources/assets/sass/*.scss'],
    dist: 'resources/assets/sass/',
    ext: '.scss'        
  }
},

When I save any scss file grunt tries to run the tasks I've specified, but csscomb:sortAll changes scss files and triggers another file change. the grunt watch runt tasks for the second time and the result is running these three tasks two times instead of once. What would you suggest?

1
Remove csscomb from the watch task and if you wanna run csscomb just call it manually..? - aug
i would configure the csscomb-task to put the output-files into another folder, and use the sass folder only for dev - hereandnow78
please post your csscomb:sortAll config for more detailed suggestions - Xavier Priour
@aug I need both of them to run automatically on every sass file I save. - Iman Mohamadi
@hereandnow78 sounds like a good Idea, but the whole purpose of using csscomb was to force every team member to write their sass file in a unique format, so I need csscomb to modify the source files. - Iman Mohamadi

1 Answers

0
votes

Just use grunt-newer, so that the second time your task gets called, nothing actually runs:

watch: {
  files: ['resources/assets/sass/*.scss'],
  tasks: ['newer:csscomb:sortAll', 'newer:sass:theme', 'newer:sass:mail']
},