Open mikeal opened 4 years ago
I have a memory of doing this for one of my projects that uses polendina but I can't find it! Maybe I undid it because it was a complicated mess.
One solution is to use webpack's lazy require resolution, check out this magic: https://github.com/rvagg/js-zcash-block/blob/master/test/browser.js
require.context()
lets me get a directory listing using a regex, see https://webpack.js.org/guides/dependency-management/#requirecontext, then the dynamic import
function does some fancy work to make the possible files available for me in the bundle. The bundle itself is pretty heavy because of this but it's all there when I need it for the tests, no need to load stuff afterward.
But that's not going to work if you have a more complicated workflow. I'll try and get my mind back to when I was considering alternatives to this, I think it was about giving the user the control over the web server and just asking for where to load files from.
For my use case, I need to attach an HTTP API implemented in Node.js, not additional static files, so these won’t for me.
I have both the client and server implementation in the same project and I want to test the client in the browser against the server implementation on localhost.
I need a way to add code to the http server that serves up the static assets so that I don’t step on any CORS problems. Not sure the best way to go about it so I figured I’d log an issue.