在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:dushaobindoudou/babel-plugin-require-all开源软件地址:https://github.com/dushaobindoudou/babel-plugin-require-all开源编程语言:JavaScript 100.0%开源软件介绍:babel-plugin-require-allconvert the referenced directory to all files under the reference directory Use in javascript source coderequireAll('dir','splitDir')dir: 需要引用的资源目录splitDir: 生成后需要去掉的目录Demo//转换前的代码
const imgs = requireAll('./imgs');// ./imas/a.png ./imgs/b.png
//转换后的代码
const $imgs_a = require('./imgs/a.png');
const $imgs_b = require('./imgs/b.png');
const imgs = {
$imgs_a:$imgs_a,
$imgs_b:$imgs_b
}
//转换前的代码
const imgs = requireAll('./imgs','./imgs');// ./imas/a.png ./imgs/b.png
//转换后的代码
const $a = require('./imgs/a.png');
const $b = require('./imgs/b.png');
const imgs = {
$a:$a,
$b:$b
} Installationnpm install --save-dev babel-plugin-require-all Usage
Via |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论