__dirname returns '/' when js file is built with webpack · Issue #1599 · webpack/webpack

I have a working express file, which I 'webpack' it but when the bundled file is run the __dirname global changes to '/'. I need the absolute path for certain functions as res.sendFile. Any help?