Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grunt-Watch not running the tasks after few iterations #514

Open
kgsnaidu opened this issue Jul 5, 2016 · 1 comment
Open

Grunt-Watch not running the tasks after few iterations #514

kgsnaidu opened this issue Jul 5, 2016 · 1 comment

Comments

@kgsnaidu
Copy link

kgsnaidu commented Jul 5, 2016

I have seen many issues which are related to this, but I haven't found the desired solution.
Problem :
While I am working with sass files or js files in my project, I want to compile/jshint those files when they were changed. So I am using grunt-contrib-watch to do this. It is working fine, but after some files changed, It is tracking the file changes, but It stops compiling( stops running the task, which has to run when the file changes ).

Code :

 grunt.initConfig({
    config: systemConfig(),
    sass: {
        current: {
            options: {
                style: 'expanded',
                lineNumber: true,
                sourcemap: 'none',
                update: true
            }
        }
    }
    jshint: {
        all: []
    },
    watch: {
        sass: {
            files: ['<%= config.PROJECT_DIR %>**/sass/*.scss'],
            tasks: ['sass:current'],
            options: {
                spawn: false,
                debounceDelay: 2000
            }
        },
        js: {
            files: ['<%= config.PROJECT_DIR %>**/js/*.js'],
            tasks: ['jshint'],
            options: {
                spawn: false,
                debounceDelay: 2000
            }
        }
    }
}); 



grunt.event.many('watch', 10, function (action, filepath, target) {
    var paths = new cleanPaths(filepath);
    var filepath = paths.filepath;
    var dirpath = paths.dirpath;
    switch (target) {

    case 'sass':
        if (grunt.file.isMatch(grunt.config('watch.sass.files'), filepath)) {
            grunt.config('sass.current.src', filepath);
            grunt.config('sass.current.dest', filepath.replace('sass/', 'css/').replace('.scss', '.css'));
            pushFile(filepath, filepath.replace('sass/', 'css/').replace('.scss', '.css'));
        }
        break;

    case 'js':
        if (grunt.file.isMatch(grunt.config('watch.js.files'), filepath)) {
            grunt.config('jshint.all', [filepath]);
            pushFile(filepath)
        }
        break;

    default:
        break;
    }
}); 

I am dynamically updating the sass configs( src and dest values).

2016-07-05 18_15_23-sourcetree

Stops compiling even when, there is no error in the sass code.

@kgsnaidu kgsnaidu changed the title Grunt-Watch not running the tasks some times Grunt-Watch not running the tasks after few iterations Jul 6, 2016
@viceice
Copy link

viceice commented Sep 13, 2017

Same here:

  • grunt-contrib-watch@1.0.0
  • grunt-sass@2.0.0

If i then modify grunt configs to force reload it is working again for some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants