sharp-loader
sharp-loader copied to clipboard
Error when trying to load file by import statement with query
I'm working on a project in Gatsby and don't want to mess about with the canned webpack configuration it provides just to load a couple of images.
So I want to use this loader with an import line in the JS file alone, and configure it with query strings.
Is this possible?
So far I'm trying
import image from 'sharp-loader!./test.png?{"outputs":[{"format": "jpg"}]}'
I was hoping this would simply convert the PNG to a JPEG. Ideally I want to specify quality level and have it optimized too.
I'm getting
TypeError: Cannot read property 'context' of null
at Object.module.exports ([...]/node_modules/sharp-loader/dist/sharp.js:232:29)
Ah thanks! Let me look into this 😄 What are you expecting image to be? Just a string? Currently sharp-loader returns a fair chunk of metadata too and was mostly built for more complex use cases. I'll see what I can do though 🎉
I don't mind what it returns -- the full object with metadata is great.
Ok great I'll see if I can get to this on the weekend!