You can define third-party standalone applications (code generators and analyzers, pre- and post- processors, database utilities, etc.) as external tools and then run them from WebStorm.
You can pass contextual information (like the currently selected file, or your project source path) to the external tools, view the tool output, and more.
The tools are defined on the External Tools page in the Settings dialog and appear as commands in the Tools menu and in various context menus. They can also be assigned keyboard shortcuts (see the Configuring Keyboards and Mouse Shortcuts section).
Many image editors create non-optimized png images. To optimize images, you can use the OptiPNG command-line tool. Let's set it up for use in WebStorm.
Create an External Tool
In the Create/Edit/Copy Tool Dialog that opens, configure the tool by providing its options:
Name: a name for the tool, which will also be displayed in WebStorm menus.
Description: a description for the tool which will be shown in the WebStorm status bar.
Group: a group for the external tools. When multiple external tools are created, it can be handy to group them into a submenu using this setting.
To see the output of the external tool in the Run Tool Window, keep the Open console checkbox selected. To only show the external tool output whenever an error occurs, clear the checkbox.
Provide the path to the program to run, its command-line arguments, and its working directory. In our case,
OptiPNGwill be run with the
-o4 $FilePath$arguments. You can make use of macros in these settings, which can refer to the project name, the current file path, a path to the PHP executable, and so on. Clicking the Insert macro button will open the Macros Dialog listing all available macros and their values.
Assign a keyboard shortcut to the External Tool
Work with the External Tool
Once the tool is created, you can run it from within WebStorm. This can be the Tools menu, a context menu in the Project Tool Window view, or the assigned Alt+I keyboard shortcut.
When the tool runs, its output is displayed in the Run tool window: