-
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
SCSS absolute image urls are not transformed #59
Comments
Note that it works for image URLs that are loaded with a import MyImage from '../static/test.jpg';
export default () => <img src={MyImage} />; Which outputs correctly: <img src="http:https://localhost:3000/_next/static/images/test-b079a0eed8d271677f1868eb5b607faa.jpg"> |
Other things I tried:
|
😕 😳 ...ok, so I just found out that all the URLs need to be relative, which I guess works best with images that are close to a SCSS file in a module directory. 🎉 |
In my example above, I mainly changed my .test {
background-image: url('../static/test.jpg');
} |
To make it work with absolute paths using aliases in our SCSS, I needed to add the aliases configuration to the webpack configuration, something like that: const path = require('path')
module.exports = {
webpack (config, options) {
config.resolve.alias['static'] = path.join(__dirname, 'static')
return config
}
} So it would work like this in our SCSS: .test {
background-image: url('~static/test.jpg'); // notice the tilde
} |
Hey Emile, I'm having the same issue as you. Can I confirm, is your |
I'm really having a hard time making this plugin work with my SASS files, so to make sure it's not my own complex configuration that is in the way, I created a new project from scratch just to test the plugin and try and make it work with CSS
url
.The simple project
And the
package.json
Note that our other project is on Next v7 (if that changes anything).
Expected behaviour
Since I'm using the
assetPrefix
Next config option, I'm hoping to see my image URL within the compiled CSS to change to something like this:http:https://localhost:3000/_next/static/test-hashHere.jpg
.Current behaviour
It's not changing at all. I'm seeing the image since the assetPrefix is the same as my default dev server and Next is correctly parsing the image since if I change the path, it fails to compile.
The text was updated successfully, but these errors were encountered: