-
Notifications
You must be signed in to change notification settings - Fork 26.2k
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
Custom loaders are not recognized by next export #21079
Comments
Potentially related https://github.com/vercel/next.js/discussions/19372 FWIW, the check isn't doing anything smart next.js/packages/next/export/index.ts Lines 333 to 343 in 41b7c52
You can set:
And it'll pass. |
same here, no settings from docs works or anything that can un-set the 'default' image loader or possibility to create a custom. I will abandon the use of this framework just because the enforcement of use vercel 'image optimation |
This does appear to be an issue, also reported with #22980. Moving convo here!
It's not enforcing you to use Vercel, this is just a bug 👍 |
Hello everybody, @leerob - do you have any further info about the ETA? |
BTW: to make my custom loader working correctly, I needed images: {
loader: "imgix",
path: "",
} the custom loader logic (should be irrelevant but for the context) |
Is this supposed to have been fixed in 10.1? I get the same error whether I use the above workaround or supply my own custom loader. |
Vote for this api:
|
+1 to receiving this. Custom loader works great with dev and production servers, but running |
This comment has been minimized.
This comment has been minimized.
+1 Adding
It will export, but when I open the resultant index.html, none of the images or JS load :( |
+1 was investigating using next.js for our company site but decided not to because of this This would have been fine:
|
Yes it's working with me also thanks 👍 |
it worked for me module.exports = {
images: {
loader: 'imgix',
path: '/',
},
} |
I faced the same problem when using
The solution is to add following config inside the next.config.js
But I don't think it is good to says
I will receive error of
Checking the code only a subset of value is allowed
Maybe we can just add
|
I want to chime in here and say that I currently do not understand how this API is supposed to work as the docs indicate. I'm building an app with Firebase and my images are stored in their Cloud Storage layer. My app uses Firebase's API to retrieve the the absolute URL for the image from Cloud Storage. To get things to work I have done configured my images: {
domains: ['firebasestorage.googleapis.com'],
}, This works in dev, but when I try to export, I get the same error as everyone else saying I need to configure a custom loader. So I've done that const myLoader = ({ src, width, quality }) => {
return `${src}?w=${width}&q=${quality || 75}`;
}; However, this still does not let me run the |
@rohan-deshpande this bug wasn't fixed. If you use custom loader for
and the export command should work. |
That causes the images to 404 with const customLoader = ({ src, width, quality }) => {
console.log('SRC', src); // this never logs
return `${src}?w=${width}&q=${quality || 75}`;
};
return <Image src={firebaseCloudStorageAbsoluteURL} layout="fill" loader={customLoader} />; |
Started a discussion for the RFC here: #26850 |
@rohan-deshpande @ArekBartnik You need to specify the path property to avoid having your url prefixed with
|
Please follow the PR here! #26847 |
… applicable (#26998) Since we are no longer accepting new built-in loaders, users may wish to use a different cloud provider. So this PR renames `dangerously-unoptimized` to `custom` to handle this case as well as the intention of `next export`. If the user doesn't add a `loader` prop, we throw an error. If the user adds a `loader` prop but it doesn't return the width, we print a warning. - Follow up to #26847 - Fixes #21079 - Fixes #19612 - Related to #26850
PR #26998 is available in 11.0.2-canary.8. You can try it out today with |
Can you make it so we can pass 'custom' as a key (alternatively to passing the loader function) and not have it fail please? It's a small thing but this caught me out on the docs for ages because it infers that custom is an accepted value - I ended up passing cloudinary personally, despite the fact I'm using Contentful, and it works fine. |
@kiranmarshall Did you try this? #21079 (comment) |
For a brand new app created with |
The If you See the Next.js 11.1.0 blog post here: https://nextjs.org/blog/next-11-1#other-image-improvements |
This fix worked for me: next.config.js:
|
I have tested the
I have double-checked that the loader property is passed in my implementation: https://github.com/Kentico/kontent-starter-corporate-next-js/blob/custom-loader/components/Image.js I have tested Next.js v11.1.0. My pull request with CI set to static export: https://github.com/Kentico/kontent-starter-corporate-next-js/pull/51 |
@Simply007 You need to do two things:
That error message looks like you did number 1 but not number 2. If you visit the error message url printed there you'll find more info: https://nextjs.org/docs/messages/next-image-missing-loader |
As I said - I have checked that I am passing I have debugged the process and the loader was initialized. -> I will add logging so that it is visible in CI log. EDIT: @styfle |
Just to share my conclusion. The problem was on my side 🤦♂️. I was not passing |
… applicable (vercel#26998) Since we are no longer accepting new built-in loaders, users may wish to use a different cloud provider. So this PR renames `dangerously-unoptimized` to `custom` to handle this case as well as the intention of `next export`. If the user doesn't add a `loader` prop, we throw an error. If the user adds a `loader` prop but it doesn't return the width, we print a warning. - Follow up to vercel#26847 - Fixes vercel#21079 - Fixes vercel#19612 - Related to vercel#26850
This is annoying. I wasted a couple of hours for something that could have been disabled with a simple configuration line. Should add something like "image-optimization: false". |
Why is this so hard to do? |
@ch-hristov Did you see this message? #21079 (comment) |
Also, we recently completely revampled the |
@leerob yes, we were using img tags and we saw warning that we should use next Image tag etc. and then we took 3 hrs trying to figure out how to put those loaders in. I think it should be easier to put a simple image in. |
hmm... I'm still getting the warning images: {
domains: ['domain.url'],
deviceSizes: [100, 500, 1200, 1920],
loader: 'custom',
path: 'https://domain.url',
}, and my loader (optimized images are in subfolders images/name.jpg, images/100/name.jpg etc...) const myLoader = ({ src, width, quality }) => {
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL
let split = ''
let source = src
if (width == 100 || width == 500 || width == 1200) {
split = src.split('/')
const img = split.pop()
split = split.join('/') + '/'
source = '/' + img
} else {
width = ''
}
return `${baseUrl}${split}${width}${source}`
} |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
10.0.5
What version of Node.js are you using?
v15.5.0
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
next export
Describe the Bug
I'm using next/image with a custom loader. The reason for the custom loader is that I've optimised all images on build-time.
When I run
next export
I will get this message:Expected Behavior
Next.js understands that I'm using a custom loader, and that a static export would work fine.
Maybe an option is to pass the custom loader as a function to next.config.js?
I would also be fine with an API like this:
To Reproduce
This is all possibly related to #19612, although I didn't get the impression that the issue was recognized as such.
Custom loader
I've got a custom loader defined:
For the example I'm just a default return statement, but normally I'm using some props and helpers here
Image component
Preprocessed images
My folder of preprocessed images looks like this:
![image](https://user-images.githubusercontent.com/882219/104502198-9bcef900-55e0-11eb-8bd5-799d2b041886.png)
In my mind, this should work, but I can't tell Next.js that I don't need a Node server.
Let me know if you need a reduced test case or an example (I already have one). I can't publicly post the full example here, yet.
The text was updated successfully, but these errors were encountered: