sdfair
sdfair

Reputation: 39

Grunt watch task not working

I am new to Grunt and am having trouble with the watch feature. I only have a couple tasks, both of which work fine when I put them into the CLI directly. Watch, however, doesn't. Any issues with this Gruntfile?

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');

};

Upvotes: 1

Views: 513

Answers (1)

Santiago Rebella
Santiago Rebella

Reputation: 2449

I am seeing you didnt register any watch task.

Just put your default task to watch, or create a specific task when you want to watch.

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

for example, or

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

Upvotes: 1

Related Questions