1

** 我希望能够使用 Compass 但 Grunt watch 无法正常工作并给我一些奇怪的错误:**

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']);
};
4

2 回答 2

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.

于 2013-11-07T16:45:07.280 回答
0

我认为这部分:

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

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

应该是这样的:

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

grunt.registerTask('watch', ['watch']);
grunt.registerTask('default', ['compass']);
于 2016-04-14T20:33:59.030 回答