使用babel递归地传输服务器文件 [英] Transpile server files recursively with babel
问题描述
我的文件夹结构如下:
functions
-- dist
-- private
-- server
---- controllers
---- middleware
------- clientAuth.js
------- someOtherAuth.js
---- index.js
---- model.js
---- router.js
我想将服务器文件夹中的所有.js文件转换为.dist.目前在我的package.json中,我有
I want to transpile all the .js files in my server folder into .dist. At present in my package.json I have
"scripts": {
"prepare": "babel ./server/**/*.js --retain-lines -d ./dist"
},
这只会转储服务器子目录中的文件,而不是服务器根目录中的文件.我可以使用什么将根目录和子目录中的所有文件转换并放入.dist文件中?
This only transpiles the files in the subdirectories in server, but not the files in the root of server. What can I use to transpile and place into .dist all the files in the root and the subdirectories?
推荐答案
如果服务器中仅包含.js
文件,则可以将./server/**/*.js
替换为./server/
If you are only going to have .js
files in your server, you could replace ./server/**/*.js
with ./server/
所以您最终会得到
"scripts": {
"prepare": "babel ./server/ --retain-lines -d ./dist"
}
如果您仍然只需要.js
扩展名,则应该有一个-x
标志来进行归档
in case you still need just the .js
extension, there should be an -x
flag to archive that
"scripts": {
"prepare": "babel ./server/ -x '.js' --retain-lines -d ./dist"
}
这篇关于使用babel递归地传输服务器文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!