I am trying to render an ejs file in my electron.js app. I am loading the ejs file using the following skeleton:
const ejs = require('ejs')
ejs.renderFile('views/list.ejs', { data: listData }, { root: __dirname }, function (err, str) {
if (err) {
console.log(err);
}
mainWindow.loadURL('data:text/html;charset=utf-8,' + encodeURI(str));
});
Now this is working properly in the dev environment(i.e. using electron . command), but when I build the app using electron-builder, and run the app, the ejs does not render and is just a blank page with undefined printed.
Any ideas why this is happening and how to fix it?