咕噜咕噜的手表不能正常工作并被绞死

时间:2015-01-01 15:12:10

标签: javascript node.js gruntjs grunt-contrib-watch

我是使用grunt的新手。我无法使用grunt手表。以下是我的咕噜文件:

 module.exports = function(grunt) {

     module.exports = function(grunt) {

      // Project configuration.
      grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        uglify: {
        my_target: {
          files: {
            'public/admin/js/developer.min.js': ['public/admin/js/developer.js']
          }
        }
      },

    cssmin: {
      target: {
        files: {
          'public/admin/css/developer2.min.css': ['public/admin/css/developer.css']
        }
      }
    },
    csslint: {
      strict: {
        options: {
          import: 2
        },
        src: ['public/admin/css/developer.css']
      },
      lax: {
        options: {
          import: false
        },
        src: ['public/admin/css/developer.css']
      }
    },
    htmlhint: {
      html1: {
        options: {
          'tag-pair': true
        },
        src: ['app/views/admin/property/*.php']
      }
    },
     jshint: {
        all: ['Gruntfile.js', 'public/admin/js/developer.js'],
    options: {
        reporter: require('jshint-stylish')
    }
      },
    jslint: { // configure the task
           // lint your project's client code
          client: {
            src: [
              'public/admin/js/developer.js'
            ],
            directives: {
              browser: true,
              predef: [
                'jQuery'
              ]
            },
            options: {
              junit: 'out/client-junit.xml'
            }
          }
        },
    qunit: {
        qunit: {
        all: {
          options: {
            urls: [
              'http://localhost:8000/tests/TestCase.php',
              'http://localhost:8000/tests/ExampleTest.php'
            ]
          }
        }
      }
      },
    jsvalidate: {
        options:{
          globals: {},
          esprimaOptions: {},
          verbose: false
        },
        targetName:{
          files:{
            src:['public/admin/js/*.js']
          }
        }
      },
      watch: {
        files: 'public/admin/js/*.js',
        task: ['uglify'],
        options: {
        nospawn: false
        },
      },

      });

      // Load the plugin that provides the "uglify" task.
      grunt.loadNpmTasks('grunt-contrib-uglify');
      grunt.loadNpmTasks('grunt-contrib-cssmin');
      grunt.loadNpmTasks('grunt-contrib-csslint');
      grunt.loadNpmTasks('grunt-contrib-jshint');
      grunt.loadNpmTasks('grunt-jslint');
      grunt.loadNpmTasks('grunt-jsvalidate');
      grunt.loadNpmTasks('grunt-htmlhint');
      grunt.loadNpmTasks('grunt-contrib-qunit');
      grunt.loadNpmTasks('grunt-contrib-watch');


      // Default task(s).
      grunt.registerTask('default', ['uglify'],['cssmin'],['csslint'],['jshint'],['jslint'],['htmlhint'],['jsvalidate'],['qunit'],['watch']);

    };

我正试图运行' uglify'任务当我的.js文件发生任何变化但它没有发生时。我得到的就是它在这里停留的以下屏幕 enter image description here。 请帮助我完成这项艰巨的任务。谢谢!!

1 个答案:

答案 0 :(得分:1)

你犯了一个小错字。而不是手表配置块中的“任务”,它应该是“任务”

        watch: {
            files: 'public/admin/js/*.js',
            tasks: ['uglify'],
            options: {
                nospawn: false
            },
        },

来源:https://github.com/gruntjs/grunt-contrib-watch