2014-08-29 77 views
1

我是Grunt的新手,並且在手錶功能時遇到問題。我只有幾項任務,當我將它們直接放入CLI時,這兩項任務都可以正常工作。但是,觀察並不是。這個Gruntfile的任何問題?Grunt手錶任務不工作

module.exports = function(grunt) { 

    grunt.initConfig({ 

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

    watch: { 
     files: '<%= uglify.build.src %>', 
     tasks: 'uglify', 
    }, 

    uglify: { 
     build: { 
     src: ['wp-content/themes/custom/js/live/*.js', 'wp-content/themes/custom/js/waypoints/*.js', 'wp-content/themes/custom/js/*.js'], 
     dest: 'wp-content/themes/custom/js/test.js' 
     } 
    }, 

    jshint: { 
     src: ['Gruntfile.js', 'wp-content/themes/custom/js/*.js'], 
     options: { 
     curly: true, 
     eqeqeq: true, 
     immed: true, 
     latedef: true, 
     newcap: true, 
     noarg: true, 
     sub: true, 
     undef: true, 
     boss: true, 
     eqnull: true, 
     browser: true, 
     globals: { 
      require: true, 
      define: true, 
      requirejs: true, 
      describe: true, 
      expect: true, 
      it: true 
     } 
     } 
    } 
    }); 

    // Load tasks 
    grunt.loadNpmTasks('grunt-contrib-uglify'); 
    grunt.loadNpmTasks('grunt-contrib-jshint'); 
    grunt.loadNpmTasks('grunt-contrib-watch'); 

    // Default task 
    grunt.registerTask('default', 'uglify'); 

}; 

回答

1

我看到你沒有註冊任何監視任務。

只需將您的默認任務設置爲觀看或創建特定任務即可。

grunt.registerTask("default", ["express","watch"]); 

例如,或

grunt.registerTask("watchmeTaskName", "watch"); 
+0

我明白了,感謝您的回答。 – sdfair 2014-08-29 18:25:36

+1

或運行'grunt watch'來運行監視任務。 – 2014-08-31 16:56:14