Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to load file by import statement with query #29

Open
tremby opened this issue Jul 19, 2018 · 3 comments
Open

Error when trying to load file by import statement with query #29

tremby opened this issue Jul 19, 2018 · 3 comments

Comments

@tremby
Copy link

tremby commented Jul 19, 2018

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)
@izaakschroeder
Copy link
Collaborator

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 🎉

@tremby
Copy link
Author

tremby commented Jul 19, 2018

I don't mind what it returns -- the full object with metadata is great.

@izaakschroeder
Copy link
Collaborator

Ok great I'll see if I can get to this on the weekend!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants