首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Grunt grunfile.js和grunt手表

Grunt grunfile.js和grunt手表
EN

Stack Overflow用户
提问于 2013-11-07 22:27:25
回答 2查看 4.5K关注 0票数 1

**我想使用指南针,但Grunt手表不工作,并给我奇怪的错误:**

代码语言:javascript
复制
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
代码语言:javascript
复制
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']);
};
EN

回答 2

Stack Overflow用户

发布于 2013-11-08 00:45:07

我重新格式化了您的代码,现在您应该看到您已经将watch config放在了compass config对象中,这是不正确的。

另外,您为什么要包含以下代码:?

代码语言:javascript
复制
grunt.registerTask('watch', ['watch']);
grunt.loadTasks('watch');

这可能也会导致一些问题,我建议删除它。

票数 1
EN

Stack Overflow用户

发布于 2016-04-15 04:33:59

我认为这一节:

代码语言:javascript
复制
grunt.registerTask('watch', ['watch']);
grunt.loadTasks('watch');

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

应该如下所示:

代码语言:javascript
复制
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');

grunt.registerTask('watch', ['watch']);
grunt.registerTask('default', ['compass']);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19838409

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档