for Windows and Linux
for macOS
⌘,⌘,⌘,⌥F7⌃⌥S
The dialog opens when you click the Add
or
Edit
button on the
File Watchers page. Use the dialog box to create a project
File Watcher based on a predefined IntelliJ IDEA File Watcher
template or to edit an existing project File Watcher.
Each template contains the settings that are optimal for the selected compiler. So in most cases, all you need is specify the path to the compiler executable.
On this page:
- Name
- Files to watch
- Tool to run on changes
- Working Directory and Environment Variables
- Advanced Options
- Options area
- Examples of customizing the behaviour of a compiler
Name
| Item | Description |
|---|---|
| Name | In this text box, type the name of the File Watcher. By default, IntelliJ IDEA suggests the name of the selected predefined template. |
Files to watch
In this area, specify the type and the range of files the File Watcher can be applied to. Changes in these files will invoke the File Watcher either immediately or upon save or frame deactivation, depending on the status of the Immediate file synchronization checkbox.
You can choose one of the predefined scopes from the drop-down list:
- Project Files: all the files within the project content roots (see Configuring Projects ).
- Project Production Files: all the files within the project content roots excluding test sources.
- Project Test Files: all the files within the project test source roots.
- Open Files: all the files that are currently opened in the editor.
VCS Scopes: these scopes are only available if your project is under version control.
- Changed Files: all changed files, that is, all files associated with all existing changelists.
-
Default: all the files associated with the changelist
Default.
| Item | Description |
|---|---|
| File type | Use this drop-down list to specify the expected type of input files.
The File Watcher will consider only files of this type
as subject for analyzing and processing.
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. |
| Scope Learn more from Scope and Scopes page. | Use this drop-down list to define the range of files the File Watcher can be
applied to.
Changes in these files will invoke the File Watcher either immediately or upon save or frame deactivation,
depending on the status of the Immediate file synchronization checkbox.
You can choose one of the predefined scopes from the drop-down list:
VCS Scopes: these scopes are only available if your project is under version control.
|
| Track only root files |
When the File Watcher is invoked on a file, IntelliJ IDEA detects all the files in which this file is included. For each of these files, in its turn, IntelliJ IDEA again detects the files into which it is included. This operation is repeated recursively until IntelliJ IDEA 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).
This option is available only for Babel, Closure Compiler, Compass, Jade, Less, Sass/SCSS, Stylus, UglifyJS, and YUI Compressor JS. |
Tool to run on changes
In this area, configure interaction with the compiler: specify the executable file to use, the arguments to pass to it, and customize the default template settings for input and output.
| Item | Description |
|---|---|
| Program | In this text box, specify the path to the executable file of the compiler
(.exe, .cmd, .bat, or other depending on the specific tool.)
Do one of the following:
|
| Arguments | In this text box, define the arguments to pass to the compiler and thus
influence its behaviour.
Among other cases, use this text box to change the default output location, that is,
specify a custom location where you want the compiler to store the files generated during compilation.
Note that if you re-define the default output location here you need to clear the Create output file from stdout checkbox
in the Advanced Options area because otherwise the content of your generated file will be overwritten by the compiler's output stream.
Do one of the following:
When specifying the arguments, follow these rules:
|
| Output paths to refresh | In this text box, specify the files where the compiler stores its output:
the resulting source code, source maps, and dependencies. In other words, tell IntelliJ IDEA where it
should search for the files generated through compilation.
Please note, that changing the value in this text box does not make the compiler store its output in another location. To do that, specify the desired output location in the Arguments text box: type the output paths using colons as separators or click the Insert Macro button to open the Macros dialog box and select the desired pattern from the list. |
Working Directory and Environment Variables
| Item | Description |
|---|---|
| Working directory | In this text box, specify the directory to which the compiler 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:
If the field is left blank, IntelliJ IDEA uses the directory of the file where the File Watcher is invoked. |
| Environment variables | Use this text box to specify a the PATH variable for a tool that is required for
starting the compiler but is not referenced in the path to it. |
Advanced Options
| Item | Description |
|---|---|
| Immediate file synchronization |
|
| Trigger watcher regardless of syntax errors |
|
| Create output file from stdout |
Some compilers generate a |
| Show console |
Use this drop-down list to define when you want the File Watcher open its dedicated console with messages.
The available options are:
|
| Output Filters | Click this button to open the Output Filters dialog
where you can manage the list of filters to distinguish the output of the
File Watcher from other output.
These filters make the basis for:
|
Options area
In this area, configure the behaviour of the File Watcher.
| Item | Description |
|---|
Examples of customizing the behaviour of a compiler
Any compiler is an external, third-party tool. Therefore the only way to influence a compiler is pass arguments to it just as if you were working in the command line mode. These arguments are specific for each tool. Below are two examples of customizing the default output location for the CoffeeScript compiler.
Suppose, you have a project with the following folder structure:

js folder.
Moreover, you can have them stored in a flat list or arranged in the folder structure that repeats the original structure under the app node.
-
To have all the generated files stored in the output
jsfolder without retaining the original folder structure under theappfolder:-
In the Arguments text box, type:
--output $ProjectFileDir$\js\ --compile --map $FileName$ -
In the Output paths to refresh text box, type:
$ProjectFileDir$\js\$FileNameWithoutExtension$.js:$ProjectFileDir$\js\$FileNameWithoutExtension$.map
As a result, the project tree looks as follows:

-
In the Arguments text box, type:
-
To have the original folder structure under the
appnode retained in the outputjsfolder:-
In the Arguments text box, type:
--output $ProjectFileDir$\js\$FileDirRelativeToProjectRoot$\ --compile --map $FileName$ -
In the Output paths to refresh text box, type:
$ProjectFileDir$\js\$FileDirRelativeToProjectRoot$\$FileNameWithoutExtension$.js:$ProjectFileDir$\js\$FileDirRelativeToProjectRoot$\$FileNameWithoutExtension$.map
As a result, the project tree looks as follows:

-
In the Arguments text box, type:
to open the