IntelliJ IDEA 2017.2 Help

Grunt Tool Window

Context menu of a Gruntfile.js - Show Grunt Tasks
View | Tool Windows | Grunt

On this page:

Accessing the Grunt Tool Window

View | Tool Windows | Grunt
- the tool window can be accessed this way only after you have opened it using the Show Grunt Tasks command.

The tool window is available only when:

  1. The Node.js runtime environment is installed on your computer.
  2. The NodeJS repository plugin is installed and enabled. The plugin is not bundled with IntelliJ IDEA, but it can be installed from the JetBrains plugin repository as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.
  3. The grunt-cli package is installed globally and the grunt package is installed in the current project, see Installing Grunt for details.
  4. At least one Gruntfile.js file is available in the current project.

The tool window opens when you invoke Grunt by choosing Show Grunt Tasks on the context menu of a Gruntfile.js in the Project tool window or of a Gruntfile.js opened in the editor.

As soon as you invoke Grunt, it starts building a tree of tasks according to the Gruntfile.js on which it was invoked. If a task has targets, the task is displayed as a node and the targets are listed under it.

If you have several Gruntfile.js files in your project, you can build a separate tasks tree for each of them and run tasks without abandoning the previously built tasks trees. Each tree is shown in a separate tab.

Building a Tree of Grunt Tasks

To build a tasks tree, do one of the following:

  • Select the required Gruntfile.js file in the Project tool window and choose Show Grunt Tasks on the context menu of the selection.
  • Open the required Gruntfile.js file in the editor and choose Show Grunt Tasks on the context menu of the editor.
  • If the Grunt tool window is already opened, click add_black.png on the toolbar and choose the required Gruntfile.js file from the list. IntelliJ IDEA adds a new node and builds a tasks tree under it. The title of the node shows the path to the Gruntfile.js file according to which the tree is built.

By default, the tasks in a tree a listed in the order in which they are defined in Gruntfile.js (option Definition order). To have them listed in the alphabetic order, click the viewMode.png toolbar button, then choose Sort by on the menu, and then choose Name.

Running Grunt Tasks and Targets

To run a task or a target from the tree, do one of the following:

  • Double click the required task or target in the tree.
  • Select the required task or target and choose Run <task name> on the context menu of the selection.
  • Select the required task or target and press Enter.
  • To run the default task, select the root node in the tree and choose Run default on the context menu of the selection.
  • To navigate to the definition of a task or target, select the required task or target in the tree and choose Jump to source on the context menu of the selection.

The task or target execution output will be displayed in the Run tool window. The name of the target is shown in the format <task name>:<target name>. The tool window shows the Grunt output, reports the errors occurred, lists the packages or plugins that have not been found, etc. The name of the last executed task is displayed on the title bar of the tool window.

To run several tasks or targets, use the multiselect mode: hold Shift (for adjacent items) or Ctrl (for non-adjacent items) keys and select the required tasks or targets, then choose Run on the context menu of the selection.

Toolbar

ItemTooltipDescription
add_black Add Gruntfile Click this button to have a tasks tree for another Gruntfile.js file built. Choose the required Gruntfile.js file from the pop-up list. IntelliJ IDEA adds a new node and builds a tasks tree under it.
minusSign.png Remove Gruntfile Click this button to remove the tasks tree under the selected node.
icon_reload_grunt.png Reload tasks Click this button to have the tasks tree under the selected node re-built. You may need a tree re-built after updating the corresponding Gruntfile.js file because Grunt does not apply changes to trees on the fly.
icon_collapse_all_on_title_bar.png Collapse all Click this button to hide all the tasks trees and have only Gruntfile.js nodes displayed.
viewMode.png Click this button to configure the current view and to change the viewing modes of the tool window, see Viewing Modes for details. Note that most of the menu items are options that you can turn on or off. An option which is on has a check mark to the left of its name. The Grunt-specific options are:
  • Grunt Settings: choose this menu item to open the Grunt Settings dialog and re-configure the current settings for Grunt and for the Node interpreter, see Grunt.
  • Sort by: choose this menu item to configure the order in which tasks are shown in trees. By default, the tasks in a tree a listed in the order in which they are defined in Gruntfile.js (option Definition order). To have them listed in the alphabetic order, click the viewMode.png toolbar button, then choose Sort by on the menu, and then choose Name.
hideSide.png Hide Click this button to hide the tool window. To have it displayed again, choose View | Tool Windows | Grunt on the main menu. The tool window appears again showing all the previously built trees of tasks.

Context Menu of a Tree

ItemDescription
Grunt Settings Choose this menu item to open the Grunt Settings dialog box and view or edit the Node.js configuration
Jump to Source Choose this menu item to open the Gruntfile.js file for which the current tree is built.
Reload tasks Choose this menu item to have the tree of tasks under the selected node re-built.
Copy Path Choose this menu item to save the path to the Gruntfile.js file according to which the current tree was built to the clipboard.
Remove Gruntfile.js Choose this menu item to remove the tree of tasks under the selected node.

Context Menu of a Task or a Target

ItemDescription
Run <task/target name> Choose this menu item to run the selected task or target.
Debug <task/target name> Choose this menu item to debug the selected task or target.
Edit <task/target name> settings Choose this menu item to open the Run/Debug Configuration dialog box and edit the predefined settings for the selected task or target.
Jump to Source Choose this menu item to open the Gruntfile.js file for which the current tree is built and navigate to the definition of the selected task or target.
Last modified: 29 November 2017

See Also

Language and Framework-Specific Guidelines: