使用babel递归地传输服务器文件 [英] Transpile server files recursively with babel

查看:80
本文介绍了使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆