简体   繁体   中英

Babel CLI have outdir be relative to transpile dir

First of all thanks for trying to help me. I'll get straight into it.

I'm trying to transpile Typescript files to JS files. These typescript files are scattered throughout a directory (all modules follow the same file structure)

The package.json command is: "build:js": "babel app/code/VendorName/**/view/adminhtml/web/ts --out-dir js --extensions \\".ts,.tsx\\" --source-maps inline"

All of the typescript files reside in different folders within VendorName (notice the **). Within it through the typescript files are in view/adminhtml/web/ts , always.

I would like to transpile all of these files and put them in their respective modules' js folders which are in:

app/code/VendorName/**/view/adminhtml/web/js . Meaning literally next to the ts folder. How can I make it, so that the --out-dir is relative to the directory that I'm transpiling? Is that even possible? Otherwise I'll have to setup a config for each and every single module I'm developing, which would be a bit of a nuisance.

The correct answer is adding the --relative flag. Position is very important "babel --verbose app/code/VenderName/**/view/adminhtml/web/ts --ignore \\"**/*.d.ts\\" --relative --out-dir ../js --extensions \\".ts\\" --source-maps inline"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM