Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Babel multiple directores into single output directory

Tags:

babeljs

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?

like image 838
PlantTheIdea Avatar asked Oct 20 '15 11:10

PlantTheIdea


2 Answers

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.

like image 71
samanime Avatar answered Nov 03 '22 00:11

samanime


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

like image 31
Tom Kleingers Avatar answered Nov 03 '22 01:11

Tom Kleingers