Trying to include an image in a halogen app based on purescript-halogen-template, spago (or esbuild through spago?) complains about not having a loader configured.
> npx spago bundle-app --to prod/index.js
[info] Build succeeded.
✘ [ERROR] No loader is configured for ".svg" files: assets/thing.svg
3 │ export const thingURL = require('../../assets/thing.svg');
[error] Bundle failed.
PNG, JPG or SVG makes no difference. I am sure I’m missing some configuration somewhere, or perhaps this is not the way to reference image files, but it does work for
spago build. Would greatly appreciate any advise.
I think the issue here is, that esbuild does not include an svg-loader by default (spago uses esbuild).
It’s not just SVG though, but PNG and JPG as well. Surely esbuild has loaders for them by default?
And shouldn’t it be possible to just associate the svg extension with a regular file loader? But I can’t find how to configure esbuild through spago at all… This web and node stuff is not exactly my strong suit…
I’m not sure but I think you cannot - personally I call esbuild outside of spago.
As far as I can remember, Esbuild has this included by default, you just have to configure it like this
As @CarstenKoenig pointed out, it’s probably a good idea to call
spago build and
esbuild ... as separate commands.