我对我的源文件运行babel,我想输出一个单独的文件,所有相关的导入都注入到文件中。
src
│ index.js
│ relative-file.js
│
└───some-folder
another-relative-file.js
索引文件需要relative-file
,relative-file
需要another-relative-file
。
index.js
没有相对要求,所有内容都注入到这个文件中。
index.js
的 require('./relative-file')
。
babel src --out-file distribution/index.js
输出一个dir会输出多个文件,就像源一样需要彼此。
babel src --out-dir distribution
答案 0 :(得分:1)
我不认为babel有助于消除需求。您需要使用像webpack这样的捆绑器与babel结合使用来实现您的目标。