Is there a way to specify an LD_PRELOAD for a sofile in an Electron snap?

Polarr uses electron with a sharp module that requires libvips that uses zlib. The app crashes in snap because of version incompatibilities between sharp, vips, and zlib. If I specify the snap to install the system libvips then sharp complains that it’s too old. If I allow sharp to provide its own newer libvips then that requires zlib version >= 1.2.9 presumably for security reasons but the system conflicts with its zlib version 1.2.8.

Does zlib 1.2.8 have security backports? It’s reasonable to assume that some people will load images from the Internet that they don’t know where they came from. If it’s okay to use zlib 1.2.8, then I can use https://github.com/lovell/sharp/issues/892#issuecomment-329983061 to make polarr run outside of a snap from the command line with LD_PRELOAD=./node_modules/sharp/vendor/lib/libz.so ./dist/polarr. Is there a way to do this LD_PRELOAD trick with electron-builder/snapcraft so that it will work with a snap? Alternatively, is there a way to set the snap environment to have a newer version of vips or zlib?

I figured out that I can use electron-builder extraResources (link broken in the documentation https://www.electron.build/configuration/configuration) in combination with "environment": { "LD_PRELOAD": "$SNAP/<path>"} in the electron-builder snap config to preload files. Symlinks seem to not work but I can copy over the targets to preload. Now I get errors like undefined symbol: g_date_copy and undefined symbol: cairo_xlib_surface_create depending on which libraries I preload. This probably gets me a little bit closer to having it work in a snap though.