This is my file structure
-main.js -SomeDir -fileA.js -fileB.js
What should I do if I want to load (inside main.js
) every file in someDir
without specifying the file names -
something like: require(./someDir/*.js)
?
var req = require.context("../someDir", true, /^(.*\.(js$))[^.]*$/igm); req.keys().forEach(function(key){ req(key); }); // or just: req.keys().forEach(req)
regex to match js
but ignore test.js
/^(?!.*test.js)((.*\.(js\.*))[^.]*$)/igm)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With