On this page:
Accessing the Grunt Tool Window
- the tool window can be accessed this way
only after you have opened it using the command.
The tool window is available only when:
-
The Node.js
framework is installed on your computer.
-
The NodeJS repository plugin is installed and enabled.
The plugin is not bundled with PyCharm, but it is available from the PyCharm plugin repository.
Once enabled, the plugin is available at the IDE level, that is, you can use it in all your PyCharm projects. See Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins for details.
-
The
grunt-cli
package is installed globally and thegrunt
package is installed in the current project, see Installing Grunt for details. -
At least one
Gruntfile.js
file is available in the current project.
The tool window opens when you invoke Grunt by choosing Open Grunt Console
on the context menu of a Gruntfile.js
in the Project tool window
or of a Gruntfile.js
opened in the editor. Use the tool window to run Grunt tasks.
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.
Grunt Tasks Tree
The tool window shows a tree of Grunt tasks. The tree is built according to the Gruntfile.js
on which Grunt 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 Open Grunt Console on the context menu of the selection. -
Open the required
Gruntfile.js
file in the editor and choose Open Grunt Console on the context menu of the editor. -
If the Grunt tool window is already opened, click the Add Gruntfile button
on the toolbar and choose the required
Gruntfile.js
file from the list. PyCharm adds a new node and builds a tasks tree in it. The title of the node shows the path to theGruntfile.js
file according to which the tree is built.
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 Grunt Console pane of the Run tool window.
The name of the target is shown in the format <task name>:<target name>
.
The pane 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 pane.
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
Item | Tooltip | Description |
---|---|---|
![]() | 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. PyCharm adds a new tab and builds a tasks tree in it.
|
![]() | Remove Gruntfile | Click this button to remove the tasks tree under the selected node. |
![]() | Reload tasks |
Click this button to have the tasks tree in the selected tab 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.
|