前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >node环境下怎样优化引入多文件(实现自动化)

node环境下怎样优化引入多文件(实现自动化)

作者头像
马克社区
发布2022-06-13 16:15:08
2130
发布2022-06-13 16:15:08
举报
文章被收录于专栏:高端IT高端IT

const mocks = []; function getJsonFiles(jsonPath) { function findJsonFile(path) { let files = fs.readdirSync(path); files.forEach(function(item) { let fPath = join(path, item); let stat = fs.statSync(fPath); if (stat.isDirectory() === true) { findJsonFile(fPath); } if (stat.isFile() === true) { // 如果需要对指定路径进行处理 let str = fPath.substring(0, 10); let newStr = fPath.replace(str, ‘./data/’); // 否则直接require mocks.push(…require(newStr)); } }); } findJsonFile(jsonPath); } getJsonFiles(’./mock/data’);

更多内容请见原文,原文转载自:https://blog.csdn.net/weixin_44519496/article/details/119809476

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档