`imageSizes` are ignored if they are in a conditional `process.env.NODE_ENV === "production"`
TimKraemer opened this issue · comments
Hi,
I've noticed that conditional config parameters are ignored and default were used.
For example, this one with changed imageSizes
will work as expected
next.config.js:
module.exports = {
images: {
loader: "custom",
imageSizes: [16, 48, 54, 64, 100, 128, 144, 384],
deviceSizes: [640, 750, 828, 1080, 1200, 1920],
},
env: {
// ...
},
}
but having a conditional in there, will ignore the changes and load the defaults:
module.exports = {
images:
process.env.NODE_ENV === "production"
? {
loader: "custom",
imageSizes: [16, 48, 54, 64, 100, 128, 144, 384],
deviceSizes: [640, 750, 828, 1080, 1200, 1920],
}
: {
// ...
},
env: {
// ...
},
}
I think it might be helpful to output a warning when the process isn't finding the values, so that one can see it will use defaults (like it warns when it doesn't find a next.config.js)
Hi @TimKraemer,
Thanks for the bug report. I now switched to the same method that Next.js uses to parse the next.config.js. Your bug should be fixed now in v1.0.1. Please give it a try.
works perfectly!