Babel path
Hello!
I have been trying to figure this out for a long time now, but it just won't work. I want to change the directory of my Babel output file to be the same as my original js file but with a different name. How can I do that ?
Thanks.
Please sign in to leave a comment.
You can use
--out-fileoption for this (https://babeljs.io/docs/usage/cli/#compile-files):But I'd stronly recommend to avoid doing this, as you will face many issues with this setup:
- this scheme can not be used efficiently for working with ES6 imports: the path inside import is not changed while transpiling, i.e. import * as mod from "./foo" is transformed into require("./foo"), but foo is original file with ES6 code itself, so you would need changing paths in generated files to require("./foo_compiled") manually everywhere
- manual changes made to generated files will result in processing them by Babel (as watcher listens to all .js files in scope, and generated foo_compiled.js is still a js), resulting in creating multiple *compiled_compiled files
- your source directory will soon become littered with this generated stuff you won't be able to exclude
etc., etc.