Excluding directories globally
Hey,
I'm trying to configure my environment to exclude dist + target directories across all my projects.
I know I can go to each project and exclude it manually, but I want to automatically exclude these directories without specifying it.
is that possible ?
Thanks
请先登录再写评论。
Please follow https://youtrack.jetbrains.com/issue/IDEA-150784 for updates.
Note that
Preferences | Editor | File Types
,Ignore files and folders
allows to ignore files/folders globally. But these folders are excluded completely - not shown in Project view, etc.@Elena Pogorelova I think that's different. When ignore folders from "Preferences | Editor | File Types", they will not visible in project files, which is not convenient sometimes. But with "Exclude", the folders are still be visible, just not be indexed. In javascript projects, I often need to "exclude" the "node_modules" dirs, not "ignore" them. Which is still not possible to do it globally now
@Nowindlee please read my comment above - didn't I mention there that ignored folders, unlike excluded ones, are excluded completely - not shown in Project view, etc.?
@Elena Pogorelova Thanks for the quick reply. Sorry, I didn't read the last sentence clearly, you did tell the differences.
Maybe what I was trying to express is, the differences between "Ignore files and folders" and "exclude" makes it not fully work well in some cases, and I really hope to have the feature "configure exclude directory globally".
This is my case:
My company project is a very big frontend javascript project, which has more than 300 sub projects/packages and each one has a "node_modules" directory. Since I often need to work on several projects at the same time, I want to open the whole project in webstorm. It may take more than 3 hours indexing all the files in "node_modules", during the indexing time, webstorm is almost freezing and I can't do anything. I want to configure "exclude" for this project, but I have to wait it complete to get the chance. If we can configure it globally, I can configure it before I open the project, that will save a lot of time.
I tried the option you mentioned to "ignore" node_modules completely. The indexing is much faster(about 3 minutes), but I often need to view code inside node_modules, I can't do it now.
After several days of investigation, I found a workaround now, it's working but very hacky:
Open the project with webstorm, and when it's blocked at "indexing", kill webstorm. Then go to the ".idea" directory and open the "project.iml" file. Modify the xml file, add an exclude pattern item for "node_modules" like this: `<excludePattern pattern="node_modules" />`, then open the project with webstorm again and everything will work well.
It's working but very inconvenient, that's why I really hope to configure "exclude" globally.
I ended up doing `find . -name target -type d | pbcopy` and vim-macroing those into the project's iml file as `<excludeFolder url="file://$MODULE_DIR$/(line of output here)" />`
Would be great if intellij could support the same sort of `"**/target"` glob that vscode does.
@Mat Schaffer,I ended up writing a script file to do the same.
Two years.
I'm thinking if I should switch to VS code now
One of my coworkers mentioned https://youtrack.jetbrains.com/issue/IDEA-127753#focus=Comments-27-2365949.0-0 which says `*target` might work too.
I haven't tried it yet and instead have opted to give VSCode a go for the week.
Google search brought me here and I discovered how to exclude directories based on their name (not excluded from the Project Tree). This example is for the folder `dist`: