External tools
The recommended way to use third-party standalone applications, such as compilers, linters, code compressors, and so on, is to configure a tool-specific File Watcher. This File Watcher will track changes to your files and run the application automatically when required. See File Watchers for details.
Alternatively, you can configure a standalone third-party application in WebStorm as an external tool. As a result, a tool-specific command is added to the main menu and possibly to context menus, so you can run the tool right from WebStorm.
You can also configure to run the tool before a run/debug configuration. And of course you can run it from the built-in Terminal Alt+F12.
WebStorm allows you to pass contextual information from your project to the external tool as command-line arguments (for example, the currently selected file or the sourcemap directive), view the output produced by the tool, and more.
There are several types of external tools that you can add to WebStorm:
Local tools are applications that run locally on your computer.
Remote tools are applications executed on a remote server over SSH.
Add a local external tool
This example demonstrates how to add ImageOptim as an external tool and use it to optimize images in your project.
Press Ctrl+Alt+S to open IDE settings and select Tools | External Tools.
Click and specify the following settings:
Name: The name of the tool that will be displayed in the WebStorm interface.
Group: The name of the group to which the tool belongs. You can select an existing group or type the name of a new group.
Description: A meaningful description of the tool.
Program: The path to the application executable file.
Arguments: The arguments passed to the executable file, as you would specify them on the command line.
Working directory: The path to the current working directory from which the tool is executed.
In our case,
ImageOptim
will be run with the-o4 $FilePath$
arguments. You can use macros that can refer to the project name, the current file path, and so on. Clicking will open the Macros dialog that lists all available macros and their values.Click OK to add the tool and then apply the changes.
Run the added local external tool
To open the selected file in the newly added tool image, do one of the following:
From the main menu, select
.Right-click a file in the Project tool window and select from the context menu.
Create a shortcut to run the tool.
In the Settings/Preferences dialog Ctrl+Alt+S, select Keymap, find the Optimize Image in my app action under the External Tools node, and assign a shortcut for it.
Add an icon to run the tool from the toolbar.
In the Settings/Preferences dialog Ctrl+Alt+S, go to . In the list of available menus and toolbars, expand the Main Toolbar node, select the item after which you want to add the ImageOptim icon, and click .
In the dialog that opens, select Icon field, and click Set icon, when ready.
, specify the icon to indicate it in theThe icon appears on the toolbar.
When the tool runs, the output is displayed in the Run tool window.
Add a remote external tool
Remote SSH external tools are configured similarly to local external tools, but also define the remote server on which they are executed and require credentials for connecting to it via SSH. For details on working with the built-in SSH terminal, see Run SSH terminal.
Press Ctrl+Alt+S to open IDE settings and select Tools | Remote SSH External Tools.
Click to open the Create Tool dialog.
This dialog provides the same set of settings as when you add a local external tool, but selecting the remote server is also suggested.
This can be one of your configured SSH configurations or a Vagrant box.
By default, WebStorm will ask you for the host, port, and relevant SSH credentials every time you run the tool on the server.
Click OK to add the tool and then apply the changes.
Run the added tool on a remote server
From the main menu, select Tools | Remote tools | <Your tool>.
In the Settings/Preferences dialog Ctrl+Alt+S, select Keymap, find the action, and assign a shortcut for it. Use the shortcut to run the tool.
After you specify the host, port, and credentials, WebStorm will connect to the server via SSH and run the command, returning the output to the Run tool window in WebStorm.