Cohars
Cohars

Reputation: 4022

Babel ignore several directories

I'm currently running Babel with a simple command :

$ babel . --ignore node_modules --out-dir dist

But I can't find a way to ignore several directories (node_modules, test), I tried a lot of things, including (in .babelrc):

  "ignore": "node_modules"
  "ignore": "/node_modules/"
  "ignore": "node_modules/**"
  "ignore": ["node_modules"]

Which doesn't work at all (node_modules are transpiled). Isn't there a simple way to achieve this (with Babel 6)?

Upvotes: 27

Views: 28251

Answers (4)

nodkz
nodkz

Reputation: 186

With Babel 7 you need to use a glob pattern:

babel . --ignore */node_modules,*/test --out-dir dist

Upvotes: 9

Naz
Naz

Reputation: 408

You can ignore multiple directories and specify a globbing pattern within the .babelrc file like this

{
    ...,
    "ignore": [
        "node_modules",
        "dir_2",
        "dir_3/**/*.js"
    ]
}

Reference: https://babeljs.io/docs/en/babelrc

Upvotes: 14

Wilfred Hughes
Wilfred Hughes

Reputation: 31161

Note that there's a known bug in babel, where it ignores only and ignore in .babelrc.

The relevant bug is T6726, which has been fixed in babel 6.14.0.

Upvotes: 6

hzoo
hzoo

Reputation: 1374

You should be able to use commas in the cli

babel . --ignore node_modules,test --out-dir dist

Upvotes: 36

Related Questions