-
Notifications
You must be signed in to change notification settings - Fork 27k
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
SCSS modules cannot load images correctly with next-images
package
#11164
Comments
Sone new things I tried: Didn't work:
What worked:
I will now check why it works in a new project but not in my project |
Alright, after some more testing I found something interesting. The problem can be reproduced when using the
For some reason this config breaks the SCSS/CSS module images resolver. Update: The same is true for the |
next-images
package
same for me |
Same here.
|
I'm not sure if it is a I faced the same issue after upgrading from By using the built-in Sass feature, background and font face I hadn't used the built-in CSS feature before and that is why I hadn't faced the issue. WorkaroundI ended up with excluding the // next.config.js
module.exports = {
// ...
webpack: (config) => {
config.module.rules.push({
issuer: {
// nextjs already handles url() in css/sass/scss files
test: /\.\w+(?<!(s?c|sa)ss)$/i,
},
test: /\.(jpg|gif|png|svg|ico)$/i,
use: [
{
loader: 'url-loader',
options: {
// sample options
limit: 8192,
outputPath: '...',
context: 'src',
name: '[path][name].[hash:8].[ext]',
publicPath: `your/public/path`,
},
},
],
});
return config;
},
// ...
}; Hope this helps. |
Works perfectly. I looked in the source code of the |
This is a bug with the tl;dr the new CSS support does not require |
Thanks guys for reporting this issue. I'll fix that in the |
@Timer Thank you. As an aside, it would be great if we can choose between |
@theshem Can you open a new issue proposing to add support for data URIs OOTB? One thing to note, using data URIs are not generally a safe default because it's incompatible with SVG sprite systems, for example. If we were to use data URIs out of the box (for small assets), SVGs would need to be excluded: |
for reference: twopluszero/next-images#31 |
Thanks to @theshem, this issue is solved now in |
Closing as it was solved upstream. Thanks everyone! |
The "fix" here appears to be mostly a workaround though. It would be nice if Next detected the use of image processing plugins like This might still be an upstream issue (some way to tie into Next's handling of images to apply optimizations?) but it seems like there's precedent here for the "detect and disable" functionality for handling images since that's what happens right now i.e. if you're using
I realize this issue mentions |
The "fix" doesn't solve importing images into js files through template literals. Given the
Example 1no
Example 2
Example 3
So what should I do to get all three |
Solved! style.module.scss
next.config.js
|
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. |
Update: Read my other comments below for a more pinpointed problem.
Bug report
Describe the bug
I tried to set a background image in a SCSS module with
background: url("./footer-region-bg.jpg") repeat;
(is in the same directory as the component). But this results in the following when fetching the image.This was working with
@zeit/next-sass
, but it doesn't with the native scss modules.To Reproduce
Load an Image from the same directory as the component in an SCSS module like mentioned above. Use the native SCSS modules from NextJs.
Expected behavior
The image should be loaded correctly
System information
The text was updated successfully, but these errors were encountered: