1

** I want to be able to use Compass but Grunt watch doesn't work and give me strange errors:**

Running "watch" task
Waiting...Verifying property watch exists in config...ERROR
>> Unable to process task.
Warning: Required config property "watch" missing.

/Applications/MAMP/htdocs/davide77.bitbucket.org/sky-route-1/node_modules/grunt-contrib-compass/node_modules/tmp/lib/tmp.js:261
  throw err;
        ^
RangeError: Maximum call stack size exceeded
module.exports = function (grunt) {

  // Project configuration.
  grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),

    compass: {

      dev: {
        src: 'sass',
        dest: 'stylesheets',
        outputstyle: 'expanded',
        linecomments: true,
        forcecompile: true,
        require: [
          'animate-sass',
          'mylib'
        ],
        debugsass: true,
        images: '/assets/images',
        relativeassets: true
      },
      prod: {
        src: 'sass',
        dest: 'stylesheets',
        outputstyle: 'compressed',
        linecomments: false,
        forcecompile: true,
        require: [
          'animate-sass',
          'mylib'
        ],
        debugsass: false,
        images: '/assets/images',
        relativeassets: true
      },
      dist: {
        src: 'sass',
        dest: 'stylesheets',
        outputstyle: 'compressed',
        linecomments: false,
        forcecompile: true,
        require: [
          'animate-sass',
          'mylib'
        ],
        debugsass: false,
        images: '/assets/images',
        relativeassets: true
      },

      watch: { // for development run 'grunt watch'
        compass: {
          files: ['sass/*.scss'],
          tasks: ['compass:dev']
        }
      }
    }
  });

  // Default task(s). 

  //grunt.registerTask('default', 'compass:dev');

  grunt.registerTask('watch', ['watch']);
  grunt.loadTasks('watch');

  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-compass');
  grunt.registerTask('default', ['compass']);
};
badsyntax
  • 9,394
  • 3
  • 49
  • 67
user2505665
  • 71
  • 3
  • 13

2 Answers2

1

I've reformatted your code, and you should see now that you've placed the watch config within the compass config object, which is not correct.

Also, why have you included this code:?

grunt.registerTask('watch', ['watch']);
grunt.loadTasks('watch');

Possibly that could be causing some issues as well, I suggest removing that.

badsyntax
  • 9,394
  • 3
  • 49
  • 67
  • it pretty obvious for me, set up the task -> `grunt.initConfig` , register it. then load it. I suggest mark your question as an answer – Adi Prasetyo Mar 09 '16 at 18:46
0

I think this section:

grunt.registerTask('watch', ['watch']);
grunt.loadTasks('watch');

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.registerTask('default', ['compass']);

should look like this:

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

grunt.registerTask('watch', ['watch']);
grunt.registerTask('default', ['compass']);
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
jdstein1
  • 117
  • 2
  • 10