Bundling assets with webpack


#1

Disclaimer: I suspect this is actually just a webpack question, but hoping I can get some help here nonetheless. Also, I’m very new to webpack, so don’t assume I know very much about how webpack works.

I’m trying to write a bucklescript bindings to the chessboardjs library. My public github repo is here.

When I use webpack to produce a single bundle, it contains all the javascript code from the chessboardjs library since my reason code depends on it, however, the bundle still relies on assets (mostly images, but also css) that are in ./node_modules/chessboardjs/www/{css,img}.

In order to workaround this, there’s a configuration option (documented here) when you create a “chessboard” to tell it where the assets are. You can see me using that configuration option here to make my simple examples work. This seems brittle, though.

I’m looking for help in how to correctly configure webpack to bundle up all the dependencies, including the images and css that the chessboardjs library needs.

Thanks!


#2

You can probably look at vendor bundles and specify that it needs to look it up through the node modules. I suggest that you consider hard locking the version of the dependencies if you aren’t already.