Comments (9)
After some digging I was able to create a workaround for the issue:
The file: /node_modules/next-optimized-images/lib/index.js
@ line 43
Replace:
// remove (unoptimized) builtin image processing introduced in next.js 9.2
if (enrichedConfig.module.rules) {
enrichedConfig.module.rules.forEach((rule) => {
if (rule.oneOf) {
rule.oneOf.forEach((subRule) => {
if (
subRule.issuer && !subRule.test && !subRule.include && subRule.exclude
&& subRule.use && subRule.use.options && subRule.use.options.name
) {
if ((String(subRule.issuer.test) === '/\\.(css|scss|sass)$/' || String(subRule.issuer) === '/\\.(css|scss|sass)$/') && subRule.use.options.name.startsWith('static/media/')) {
subRule.exclude.push(/\.(jpg|jpeg|png|svg|webp|gif|ico)$/);
}
}
});
}
});
}
with
// remove (unoptimized) builtin image processing introduced in next.js 9.2
if (enrichedConfig.module.rules) {
enrichedConfig.module.rules.forEach((rule) => {
if (rule.oneOf) {
rule.oneOf.forEach((subRule) => {
if (
subRule.issuer && !subRule.test && !subRule.include && subRule.exclude
/* && subRule.use && subRule.use.options && subRule.use.options.name */
) {
if ((String(subRule.issuer.test) === '/\\.(css|scss|sass)$/' || String(subRule.issuer) === '/\\.(css|scss|sass)$/')/* && subRule.use.options.name.startsWith('static/media/') */) {
subRule.exclude.push(/\.(jpg|jpeg|png|svg|webp|gif|ico)$/);
}
}
});
}
});
}
from next-optimized-images.
Facing the same issue with Next 12.0.4
The files in the .next/static/media folder are structured like module files. e.g.
module.exports = "/_next/static/images/filename_generated_by_next_optimized_images"
from next-optimized-images.
same issue with Next 12.0.4
from next-optimized-images.
Same with 12.0.7
from next-optimized-images.
+1
from next-optimized-images.
same problem in nextjs 12.1 :(
from next-optimized-images.
@wodka For the time being @SStoliarchuk's fix worked for me, forked it on https://github.com/jorgev259/next-optimized-images
from next-optimized-images.
+1. Had to stop using for now.
from next-optimized-images.
After some digging I was able to create a workaround for the issue: The file:
/node_modules/next-optimized-images/lib/index.js
@ line 43 Replace:// remove (unoptimized) builtin image processing introduced in next.js 9.2 if (enrichedConfig.module.rules) { enrichedConfig.module.rules.forEach((rule) => { if (rule.oneOf) { rule.oneOf.forEach((subRule) => { if ( subRule.issuer && !subRule.test && !subRule.include && subRule.exclude && subRule.use && subRule.use.options && subRule.use.options.name ) { if ((String(subRule.issuer.test) === '/\\.(css|scss|sass)$/' || String(subRule.issuer) === '/\\.(css|scss|sass)$/') && subRule.use.options.name.startsWith('static/media/')) { subRule.exclude.push(/\.(jpg|jpeg|png|svg|webp|gif|ico)$/); } } }); } }); }
with
// remove (unoptimized) builtin image processing introduced in next.js 9.2 if (enrichedConfig.module.rules) { enrichedConfig.module.rules.forEach((rule) => { if (rule.oneOf) { rule.oneOf.forEach((subRule) => { if ( subRule.issuer && !subRule.test && !subRule.include && subRule.exclude /* && subRule.use && subRule.use.options && subRule.use.options.name */ ) { if ((String(subRule.issuer.test) === '/\\.(css|scss|sass)$/' || String(subRule.issuer) === '/\\.(css|scss|sass)$/')/* && subRule.use.options.name.startsWith('static/media/') */) { subRule.exclude.push(/\.(jpg|jpeg|png|svg|webp|gif|ico)$/); } } }); } }); }
it is works
from next-optimized-images.
Related Issues (20)
- Create an example in Next.js /examples folder
- Image is not getting compressed in my NEXT app HOT 2
- imagemin-svgo version 10.0.0 compatibility
- Bump sharp to v0.29.0 HOT 2
- Error: Input buffer contains unsupported image format HOT 1
- Error: Objects are not valid as a React child HOT 1
- require() of ES Module (.\node_modules\imagemin-svgo\index.js) from (.\node_modules\next-optimized-images\lib\loaders\img-loader.js) not supported. HOT 3
- Next 12 - got next dev, next build and next export to work - update documentation HOT 1
- Problem when using next.js github pages template + next-optimized-images
- Dynamic urls not supported
- Support for imagemin-mozjpeg v10 HOT 2
- .svg?sprite are included in client side bundle
- Images within client-side-only loaded components arenβt optimized HOT 1
- TypeError: unsupported file type: undefined (file: undefined) HOT 5
- Warning from nextjs when optimizeImages and inlineImageLimit are used HOT 2
- Compatible with Next 13? HOT 2
- kgroundimage using in reactjs
- image optimization issue
- add support for svg components
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-optimized-images.