I'm bundling server-side code with a dependency on errorhandler, which itself fs.readFileSync's a css file. This isn't getting included in my bundle, and when I attempt to execute the bundle, it breaks immediately with a:
Error: ENOENT: no such file or directory, open '/public/style.css'
My goal is to bundle some server-side node, tree-shake it, and shove it into a docker container that I can simply execute. My repo setup and custom registries make it impractical to run npm install
inside a docker container when building. Webpack seems like a solid strategy.
I found one suggestion that suggested adding this to my webpack config:
module.exports = {
...
node: {
__dirname: false,
__filename: false,
},
...
}
This did indeed change the error to
Error: ENOENT: no such file or directory, open '/Users/{me}/Projects/errorhandler-ts-webpack-err/dist/public/style.css'
Which seems moot. I've been looking for webpack loaders that will stringify in-line fs.readFileSync
calls but I've not been successful yet.
Example repo here: https://github.com/TylerR909/errorhandler-ts-webpack-err/tree/no-typescript
I'm hoping to get this dependency and others like it building and running.