question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Relative path images of SASS @import is not supported

See original GitHub issue

Choose one: this is a 🐛 bug report.

💻 Code Sample

main.scss

@import '../components/topbar/index.scss';

topbar/index.scss

.topbar {
  height: 60px;
  background: #f60 url("./play.png") repeat;
  font-size: 2em;
}

🤔 Expected Behavior

main.css

.topbar {
  height: 60px;
  background: #f60 url("md5xxxxxxx.png") repeat;
  font-size: 2em;
}

😯 Current Behavior

main.scss: Cannot resolve dependency './play.png'

🌍 Your Environment

Software Version(s)
Parcel 1.4.1
Node 8.6.0
npm/Yarn npm
Operating System macOS 10.12.6

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:6
  • Comments:22 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
devnielcommented, Mar 3, 2019

Hello, I had a similar problem with this kind of import

@import '../node_modules/@ibm/plex/scss/ibm-plex.scss';,

got solved by wrapping it with url()

@import url('../node_modules/@ibm/plex/scss/ibm-plex.scss');

Thanks!

7reactions
breadadamscommented, Jan 23, 2018

I’ve been getting around it importing media, ie:

import audio from './song.mp3'
import bgImage from './bg_image.jpg'
import someLogo from './logo.png'

And then inserting those where necessary with js. Not sure if that’s of any help @spion

Read more comments on GitHub >

github_iconTop Results From Across the Web

SCSS - usage of image files with relative path are not working
import './../scss/main.scss'. When I try to build this project with webpack, I get an error, that the image.png file can not be resolved....
Read more >
sass-loader - webpack - JS.ORG
The loader will first try to resolve @import as a relative path. If it cannot be resolved, then the loader will try to...
Read more >
How to avoid long relative paths import in your angular app
This looks weird, this nesting path depends on how deep your component is, where you are importing the variables scss/less file.
Read more >
CSS - Parcel
CSS assets can contain dependencies referenced by @import syntax, as well as references to images, ... relative paths are not allowed in custom...
Read more >
Relative Paths Not Working in SCSS file in Visual Studio Code ...
On his MacBook, my colleague has added import statements to his SCSS files like this: @import '~styles/_Mixins';.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found