Question

I am new to grunt and am trying to configure a gruntfile to watch for changes and run the proper compiler (compass, jst, and jshint for right now)

Compass, JST, and JsHint all work fine on their own but when I try to call them from watch they don't activate. The gruntfile detects the change but does nothing.

module.exports = function (grunt) {


    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        compass: {
            dev: {
                files: {
                    "stylesheets/global.css": "sass/*.scss"
                }
            }
        },
        jst: {
            compile: {
                files: {
                    "javascript/compiled/templates.js": ["templates/*.html"]
                }
            } 
        },
        jshint: {
            files: ['gruntfile.js', 'javascript/**/*.js'],
            options: {
                // options here to override JSHint defaults
                globals: {
                    jQuery: true,
                    console: true,
                    module: true,
                    document: true
                }
            }
        },
        watch: {
            css: {
                files: 'sass/*.scss',
                task: ['compass']
            },
            templates: {
                files: 'templates/*.html',
                task: ['jst']
            },
            scripts: {
                files: ['javascript/**/*.js', 'gruntfile.js'],
                task: ['jshint']
            },
            options: {
                spawn: true
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-jst');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-compass');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('default', ['jst', 'compass', 'watch']);
};

What am I doing wrong? i have run gem install on all the gems and their dependencies.

Was it helpful?

Solution

tasks within the watch config is plural. Change task: ['compass'] to tasks: ['compass'].

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top