-
Notifications
You must be signed in to change notification settings - Fork 91
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
Optimisation not working in background image #123
Comments
I use SCSS & next-sass package .... url('....jpg') does not get into my dist folder |
Not a pretty workaround is to inline style the background...
|
I'm getting a link to
The file referenced by the I see the same behavior with |
I ran into this issue as well. Any idea @cyrilwanner? |
I tried this and it seems to work
|
I've run into this error also - will attempt this solution -> can confirm @mpetricek 's solution works :D |
I'm having the exact same issue, which prevents me from using background images on pseudo-elements (before, after), for instance. |
Temporarily fixed on my project by adding this to next.config.js ...
const optimizedImagesCSSFix = (nextConfig = {}) => {
return Object.assign({}, nextConfig, {
webpack(config, options) {
if (config.module.rules) {
config.module.rules.forEach((rule) => {
if (rule.oneOf) {
rule.oneOf.forEach((subRule) => {
if (subRule.type && subRule.type === 'asset/resource' && subRule.exclude) {
subRule.exclude.push(/\.(jpg|jpeg|png|svg|webp|gif|ico)$/);
} else if (
subRule.issuer &&
!subRule.test &&
!subRule.include &&
subRule.exclude &&
subRule.use &&
subRule.use.options &&
subRule.use?.options?.name
) {
if (
String(subRule.issuer).includes('/\\.(css|scss|sass)(\\.webpack\\[javascript\\/auto\\])?$/') &&
subRule.use.options.name.startsWith('static/media/')
) {
subRule.exclude.push(/\.(jpg|jpeg|png|svg|webp|gif|ico)$/);
}
}
});
}
});
}
if (typeof nextConfig.webpack === 'function') return nextConfig.webpack(config, options);
return config;
}
});
};
const nextPlugins = [[optimizedImages, optimizedImagesConfig], optimizedImagesCSSFix];
... |
For external and inline css background image url not optimizing
The text was updated successfully, but these errors were encountered: