[英]How to load all files in a subdirectories using rollup without require statements
I have a large amount of javascript files in src/, I don't want to manually go in and require all my files. 我在src /中有大量的javascript文件,我不想手动输入所有文件。
|- /src
|- a.js
|- b.js
|- c.js
|- more.js
| - index.js
index.js index.js
import a from 'a.js'
import a from 'b.js'
import a from 'c.js'
//import more
export default {
a,
b,
c,
// more
}
Is there a way to do this with rollup or a plugin that someone has written to do this? 有没有办法使用汇总或有人编写的插件来做到这一点?
English is not my native language; 英语不是我的母语。 please excuse typing errors.
请原谅输入错误。
When you export a module it is automatically imported, so you can do: 导出模块时,它会自动导入,因此您可以执行以下操作:
export * from 'a.js';
export * from 'b.js';
// ...
If you don't need to import those modules later, but just include them in the bundle, you can import them like this: 如果您以后不需要导入那些模块,而只是将它们包括在捆绑软件中,则可以这样导入它们:
import 'a.js';
import 'b.js';
And so on. 等等。
You can also take a look at https://www.npmjs.com/package/rollup-plugin-glob-import . 您也可以查看https://www.npmjs.com/package/rollup-plugin-glob-import 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.