for example if I want to add require("index.less")
to all files and ignore this line if the file does not exists.
how do I do it (including using of loaders for example).
One option would be to set up require.context and then check if the file exists against that.
Rough idea:
var req = require.context('./', false, /^index.less$/);
if(req.keys().includes('./index.less')) {
req('./index.less');
}
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