Unable to get Grunt watch task to function properly

Recently delving into Grunt, I've encountered some issues with the watch feature. While my tasks work fine when run directly from the CLI, the watch command seems to be causing trouble. Could there be any problems with my current Gruntfile setup?

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

};

Answer №1

It appears that you have not set up any watch tasks yet.

You can simply add your default task to include watching, or create a new task specifically for watching purposes.

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

For instance, you could also do:

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

In jQuery, apart from utilizing class, id, and text properties, what other methods can be used to pass a variable within an element?

Currently, I am facing a scenario where the class and id attributes are already assigned, but I need to pass a variable to jQuery. How should I go about this? Here is the HTML code: <input type="text" id="cannot_change_this" class="rather_ ...

I am unable to incorporate added height into the component

In my current project using react.js, material-ui, and sass, I had the task of creating a ChatBit component. After writing it, here is the code: customComponent.js file. // @flow import * as React from 'react'; import { useState } f ...

Incorporate a NodeJS express object into AngularJS 1.6

I am currently facing a challenge with passing parameters from a NodeJS API to AngularJS so that I can retrieve data for a specific page. My situation is an extension of the issue discussed in this question: How do I pass node.js server variables into my a ...

Step-by-step guide on sending a JSON object to a web API using Ajax

I have created a form on my website with various fields for user entry and an option to upload a file. After the user fills out the form, my JavaScript function converts the inputs into a JSON file. I am attempting to send this generated JSON data along wi ...

Running two different versions of the same React-App concurrently: A step-by-step guide

I currently have a react-app that was created using create react app. There is an older branch that is approximately 1 month old, as well as a current branch. I am interested in running both branches simultaneously and making changes to the current branch ...

AngularJS - Make Checkbox Checked When Value is True

Here is a user json object data: var users = [ { firstName: 'Sven', lastName: 'Butzbak', userID: '1', // TODO refactor to _id gender: 'male', a ...

Place the outcome of the function into the div element's attribute

As a newcomer to HTML and JavaScript, I recently dove into using 3Dmol.js. Following a tutorial, I was able to create this code snippet that actually works: <script src="http://3Dmol.csb.pitt.edu/build/3Dmol-min.js"></script> <div id="el ...

Value binding in Angular being passed to ng-click function rather than the actual value

An HTML link is causing me some trouble: <div class="menu-item" ng-repeat="pageName in pages"> <a ng-click="routing.open('{{pageName}}')">{{pageName}}</a> </div> When clicked, this link triggers the 'open' ...

What is the best way to retrieve the current value of a React useState hook within a setInterval function while using Highcharts

import Error from 'next/error' import React, { useState, useEffect } from 'react' import Highcharts from 'highcharts' import HighchartsReact from 'highcharts-react-official' function generateChart() { const [co ...

Dynamic Selection of JSON Key-Value Pairs in React Framework

My json data structure resembles the following: { "index": 1, "ln": "27953", "name": "Product 1", "availability": { "day0726": "G", "day0727": "G", "day0728": "G", } } I am looking for a way to dynamically disp ...

Adding the tasksMap to the dependency array in the React useEffect hook will result in an endless loop

I'm facing an issue with adding tasksMap to the useEffect dependency array, as it causes an infinite loop. Can someone guide me on how to resolve this? To ensure that the user sees an updated view of tasks that are added or modified, I need the app to ...

Accessing API using Next.js 14

I am facing an issue with the following code which is written in next.js. The error displayed on the console is: GET http://localhost:3000/products/porducts.json 404 (not found) Additionally, I'm encountering this error: Uncaught (in promise) SyntaxE ...

Exploring the world of mocking and stubbing in protractor

I am interested in testing my angular application using protractor. The app includes an API Module that communicates with the server In these tests, I would like to mock this API Module. I am not looking to perform full integration tests, but rather tests ...

Encountering difficulties in installing the 'weak' module using npm installation process

I am currently attempting to configure prerender.io with a Node Express server on my Windows 10 system. I have installed Node.js in order to utilize npm packages, including prerenderjs, the Node server, and PhantomJS to kickstart SEO for my Node Express se ...

Issue with Angular Reactive form: Checkbox checked property not binding correctly when the page initially loads

Looking to achieve Two-way data binding of Checkbox in Angular Reactive forms. After checking the checkbox, I am updating the 'isdateChkd' variable and storing it in the state. Despite the variable being set to TRUE, the checkbox does not get aut ...

Getting the dimensions of an image using a path in JavaScript

I am trying to display a div with an image, its name, size, and download link using jQuery. Here is the code I have created: var image = 'image/example.png' $('#download').attr("href", result2); $('.image').attr("src", re ...

Updating specific data in MongoDB arrays: A step-by-step guide

{ "_id":{"$oid":"5f5287db8c4dbe22383eca58"}, "__v":0, "createdAt":{"$date":"2020-09-12T11:35:45.965Z"}, "data":["Buy RAM","Money buys freedom"], & ...

What is the best way to conceal a section of a div using CSS/React?

I am attempting to create a design where the entire content of a div is displayed initially, and then after clicking a button labeled "show less", only 300px of the content will be shown with the button changing to "show more". <div className="bod ...

Executing a for loop concurrently by utilizing async/await promises

In my current code, I am using a for loop structured like this: async myFunc() { for (l of myList) { let res1 = await func1(l) if (res1 == undefined) continue let res2 = await func2(res1) if (res2 == undefined) continue ...

Using jQuery to toggle visibility on click within WordPress

Looking for a way to make three buttons change color on hover and display different content when clicked? You're not alone! Despite searching through tutorials and forums, the solution remains elusive. The buttons are structured like this: <div i ...