- Open the Project Settings and click File Watchers.
-
The File Watchers page that opens, shows the list of File Watchers that are already configured in the project.
Click the Add button
or press Alt+InsertAlt+Insert and do one of the following:
- Choose the predefined template to create the File Watcher from. The choice depends on the transpiler you are going to use.
- To set up a transpiler of your choice, choose Custom.
- In the Name text box, type the name of the File Watcher. By default, PhpStorm suggests the name of the selected predefined template.
- Provide a brief description of the File Watcher's functionality. Predefined templates already contain general information regarding the accepted input and produced output. Expand or update the description, if, for example, you have two File Watcher that apply to the same source code but differ from each other in some configuration settings. .
In the Options area of the New Watcher dialog box, configure the behaviour of the File Watcher: the events that will invoke it, from which files it can be invoked, when you want the console shown, etc.
-
Specify whether you want the File Watcher to interact with the PhpStorm syntax parser:
- To have the File Watcher ignore update, save, and change focus events in files that are syntactically invalid and start only in error-free files, select the Check file for syntax errors check box.
- To have the File Watcher start regardless of the syntactical correctness of a files, clear the the Check file for syntax errors check box. The File Watcher will start upon update, save, or frame deactivation, depending on the status of the Immediate file synchronization check box.
-
Specify the events which will invoke the File Watcher:
- To have the File Watcher invoked as soon as any changes are made to the source code, select the Immediate file synchronization check box.
- Clear the check box to have the File Watcher started upon save (, ) or when you move focus from PhpStorm (upon frame deactivation).
-
Specify how you want the File Watcher to deal with dependencies.
When the File Watcher is invoked on a file, PhpStorm detects all the files in which this file is included.
For each of these files, in its turn, PhpStorm again detects the files into which it is included. This operation is repeated recursively until PhpStorm reaches the files
that are not included anywhere within the specified scope. These files are referred to as root files (do not confuse with content roots).
- To run the File Watcher only against the root files, select the Track only root files check box.
- Clear the check box to run the File Watcher against the file from which it is invoked and against all the files in which this file is recursively included within the specified scope.
Note
This choice is available only for CSS, SASS, SCSS, LESS, and Dart.
-
In the Show console drop-down list, specify when you want the console shown.
The available options are:
- Always: when this option is chosen, the File Watcher opens the console when it starts.
- Error: when this option is chosen, the File Watcher opens the console only if any errors occur in transpilation.
- Never: choose this option to suppress opening the console under any circumstances.
-
Configure the output filters to distinguish the output of the File Watcher from other output.
These filters make the basis for:
- Displaying paths to the File Watcher output files as links in error and other messages and logs. When you click such link, the corresponding file is opened in the editor.
- Error highlighting in the output files.
In the Watcher Settings area, configure interaction with the transpiler: specify the path to the executable file, the arguments to pass to it, the acceptable input and expected output file types, etc.
-
In the Program text box, specify the location of the transpiler's executable file (.exe, .cmd, .bat
or other depending on the specific tool. .jar archives are also acceptable but defining path variables for them is not supported.
Do one of the following:
- Type the path explicitly.
- Click the Browse button
to open the Select Path dialog box
and navigate to the desired location. - Click the Insert Macro button to open the Macros dialog box where you can select the relevant macro from the list.
-
From the File type drop-down, choose the expected type of input files.
The File Watcher will consider only files of this type
as subject for analyzing and processing.
Note
File types are recognised based on associations between file types and file extensions.
By default, the field shows the file type in accordance with the chosen predefined File Watcher template.
- In the Scope drop-down list, define the range of files the File Watcher can be applied to.
-
In the Arguments text box, define the arguments to pass to the transpiler in one of the following ways:
- Type the list of arguments in the text box.
- Click the Insert Macro button to open the Macros dialog box where you can select the desired macro from the list.
When specifying the arguments, follow these rules:
- Use spaces to separate individual arguments.
- If an argument includes spaces, enclose the spaces or the argument that contains the spaces in double quotes, for example, some" "arg or "some arg".
- If an argument includes double quotes (e.g. as part of the argument), escape the double quotes by means of the backslashes, for example, -Dmy.prop=\"quoted_value"\.
-
In the Working Directory text box, specify the directory to which the transpiler will be applied.
Because the tool is always invoked in the context of a file, the default working directory is the directory of the current file. This setting is specified in all predefined templates
through a macros $FileDir$. To update this default settings, do one of the following:
- Type the path explicitly in the text box.
- Click the Browse button
to open the Select Path dialog box
and navigate to the desired location.
- Click the Insert Macro button to open the Macros dialog box, where you can select the desired macro from the list.
Tip
If the field is left blank, PhpStorm uses the directory of the file where the File Watcher is invoked.
-
In the Output Paths text box, specify the files where the transpiler stores its output: the resulting source code, source maps,
and dependencies. Based on this settings, PhpStorm detects files generated through transpilation.
Do one of the following:
- Type the output paths manually. Use colons as separators.
-
Click the Brose Browse button
to open the Select Path dialog box
and navigate to the desired location.
- Click the Insert Macro button to open the Macros dialog box, where you can select the desired macro from the list.
-
Use the Create output from stdout check box to specify how you want the output file generated.
- To have PhpStorm read the native transpiler's output (standard output stream (stdout)) and generate the resulting files from it, select the Create output from stdout check box.
- To have the transpiler write its output directly to the files specified in the Output paths field, clear the check box.
Tip
Some transpilers generate a standard output stream (stdout) file, others do not, which may lead to errors. Therefore it is strongly recommended to preserve the default setting.
- Optionally, define environment variables. For example, specify the the path variable for the tool that is required for starting the transpiler but is not referenced in the path to it. In most cases it is Node.js or ruby.exe. Such situation may happen if you installed the transpiler manually but not through the Node Package Manager or gem manager and its installation folder is not under Node.js or ruby.
Enabling and disabling file watchers
To toggle the enable/disable status of a File Watcher, select/clear the check box next to it on the File Watchers page of the Settings dialog box. If an error occurs while a File Watcher is running, the File Watcher is automatically disabled. To restore the status, enable the File Watcher manually.

that run in the background and perform the following: