PlantTheIdea
PlantTheIdea

Reputation: 16359

Babel multiple directores into single output directory

I've scouered the documentation for Babel and cannot seem to find an answer, so I turn to the glorious community.

With a directory structure like this:

src/
    folder1/
        file1.js
        file2.js
    folder2/
        file3.js
    folder3/
        file4.js
        file5.js

I want Babel to transpile all files into a flattened directory:

lib/
    file1.js
    file2.js
    file3.js
    file4.js
    file5.js

No matter what I try, Babel always inherits the src/ directory structure. Any ideas?

Upvotes: 28

Views: 19389

Answers (2)

Tom Kleingers
Tom Kleingers

Reputation: 261

To expand on samanime's answer, if you're using babel-cli, you can simply use a wildcard on your parent folder...

babel src/** -d lib

Upvotes: 14

samanime
samanime

Reputation: 26537

If you are using babel-cli, you can do this:

babel folder1 folder2 folder3 folder4 -d lib

which works fine if you have a limited number of folders. It'll output them all flattened.

Upvotes: 51

Related Questions