gruntjs - How do i run different sass sub tasks depending on what watched files have changed? -


is there way watch different sets of files , run different tasks based on set have changed?

the reason ask because working several separate sites different countries (uk,us, french, german). core sass in uk folder, there separate french, german , folders sass overrides core css in.

my grunt file looks so:

module.exports = function(grunt) {      grunt.initconfig({         pkg: grunt.file.readjson('package.json'),         watch: {             files: ['../style/v4/sass/**/*.scss', '../../us/style/v4/sass/**/*.scss', '../../france/style/v4/sass/**/*.scss', '../../germany/style/v4/sass/**/*.scss'],             tasks: ['sass:uk'],             options: {                 spawn: false             },         },         sass: {             uk: {                 options: {                     style: 'compressed',                     sourcemap: true,                     compass: true                 },                 files: {'../style/v4/css/screen.css': '../style/v4/sass/screen.scss'}             },             us: {                 options: {                     style: 'compressed',                     sourcemap: true,                     compass: true                 },                 files: {'../../us/style/v4/css/screen.css': '../../us/style/v4/sass/screen.scss'}             },             fr: {                 options: {                     style: 'compressed',                     sourcemap: true,                     compass: true                 },                 files: {'../../france/style/v4/css/screen.css': '../../france/style/v4/sass/screen.scss'}             },             de: {                 options: {                     style: 'compressed',                     sourcemap: true,                     compass: true                 },                 files: {'../../germany/style/v4/css/screen.css': '../../germany/style/v4/sass/screen.scss'}             }         }     });      grunt.loadnpmtasks('grunt-contrib-watch');     grunt.loadnpmtasks('grunt-contrib-sass');      grunt.registertask('default', ['watch']);  }; 

so can see, @ moment when of core uk files or french, german, files changed run sass:uk compilation task.

what want happen if uk files change run of sass sub-tasks compile scss. if france scss files change run sass:fr task, if scss files change run sass:us task , on.

how structure gruntfile achieve this?

just in case having same issue, solved setting individual watching tasks different countries. pretty obvious really:

module.exports = function(grunt) {      grunt.initconfig({         pkg: grunt.file.readjson('package.json'),         watch: {             uk: {                 files: ['../style/v4/sass/**/*.scss'],                 tasks: ['sass'],                 options: {                     spawn: false                 }             },             us: {                 files: ['../../us/style/v4/sass/**/*.scss'],                 tasks: ['sass:us'],                 options: {                     spawn: false                 }             },             fr: {                 files: ['../../france/style/v4/sass/**/*.scss'],                 tasks: ['sass:fr'],                 options: {                     spawn: false                 }             },             de: {                 files: ['../../germany/style/v4/sass/**/*.scss'],                 tasks: ['sass:de'],                 options: {                     spawn: false                 }             }         },         sass: {             uk: {                 options: {                     style: 'compressed',                     sourcemap: true,                     compass: true                 },                 files: {'../style/v4/css/screen.css': '../style/v4/sass/screen.scss'}             },             us: {                 options: {                     style: 'compressed',                     sourcemap: true,                     compass: true                 },                 files: {'../../us/style/v4/css/screen.css': '../../us/style/v4/sass/screen.scss'}             },             fr: {                 options: {                     style: 'compressed',                     sourcemap: true,                     compass: true                 },                 files: {'../../france/style/v4/css/screen.css': '../../france/style/v4/sass/screen.scss'}             },             de: {                 options: {                     style: 'compressed',                     sourcemap: true,                     compass: true                 },                 files: {'../../germany/style/v4/css/screen.css': '../../germany/style/v4/sass/screen.scss'}             }         }     });      grunt.loadnpmtasks('grunt-contrib-watch');     grunt.loadnpmtasks('grunt-contrib-sass');      grunt.registertask('default', ['watch']);  }; 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -