Search code examples
ecmascript-6webstormbabeljs

How to prevent WebStorm 2016.2 Babel plugin from compiling in certain directories?


I've enabled the Babel File Watcher, as described here.

It does its job, but also seems to get active in places I don't want - my app/lib, server and node_modules folders.

The Webstorm blog (link above) suggests making a separate "Scope" that would exclude unwanted directories. I'm looking for other solutions, since:

  • I would prefer the solution to be in version controlled files, not the WebStorm preferences

I tried setting up .babelrc as such:

{
  "presets": ["es2015"],
  "ignore": [
    "node_modules/**",
    "app/lib/**",
    "server/**"
  ]
}

This did not change the behaviour.

I presume the Babel "presets" system cannot be overridden?


Solution

  • The only solution is using scopes as suggested in blog - when using default scope (Project Files) Babel watcher listens to all .js files in your project. So, Babel will be started for all them - and .babelrc is checked once the process is started, not before starting it. Scopes are stored with project, in .idea folder. If you like to version control scopes, use 'shared' type - see https://www.jetbrains.com/help/webstorm/2016.2/scope.html#d317067e51