I have been running a command to turn .jsx files into .js files one at a time:
JavaScript
x
2
1
npx babel App.jsx --out-file App.js --plugins=@babel/plugin-transform-react-jsx
2
I want to do it for everything in a directory. I read through the help command’s options and it seems like I should be able to do this
JavaScript
1
2
1
npx babel -d mydirectory -x .jsx --plugins=@babel/plugin-transform-react-jsx
2
But that says it requires filenames, despite providing a directory.
What’s the right syntax to get this to work?
Advertisement
Answer
According to babel docs, it appears the syntax is
JavaScript
1
2
1
npx babel mydirectory --out-dir dist -x .jsx --plugins=@babel/plugin-transform-react-jsx
2