Parcel: How can I make sass ignore url() paths?

Created on 5 Aug 2019  ·  3Comments  ·  Source: parcel-bundler/parcel

❔ Question

How can I make the sass compilation task ignore all url() references and leave those paths intact?

🔦 Context

For example, I have a background image that I store in a public folder on the server. Parcel is attempting to find the jpg, if not found, throws an error. If found, it copies the jpg file to the same directory of the compiled css file.

💻 Code Sample

Source sass path: /resources/assets/scss/app.scss
Dist font path: /assets/img/
Dist css path: /assets/css/

parcel watch resources/assets/scss/app.scss --out-dir assets/css --public-url /assets/css

.hero {
    background-image: url(../img/a_background_image.jpg);
}

Parcel tries to find/resources/assets/img/a_background_image.jpg and then copies it to /assets/css/a_background_image.jpg

I would like for sass to not resolve those URLs, just leave them as they are. Is that possible?

🌍 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.12.3
| Node | 10.16.0
| npm/Yarn | 1.17.3
| Operating System | Ubuntu 16.04 via WSL in Windows 10 Pro build 1903

Question

Most helpful comment

I am having this issue too. I can't have parcel copying the image defined in url() to my 'dist' directory, and re-writing the path. I need url() to be left alone in my scss file.

All 3 comments

Is that possible?

No, that isn't possible unfortunately.

Duplicate issues: https://github.com/parcel-bundler/parcel/issues/1087, https://github.com/parcel-bundler/parcel/issues/1186

I am having this issue too. I can't have parcel copying the image defined in url() to my 'dist' directory, and re-writing the path. I need url() to be left alone in my scss file.

Is there any workaround available?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidnagli picture davidnagli  ·  3Comments

adamreisnz picture adamreisnz  ·  3Comments

donaldallen picture donaldallen  ·  3Comments

philipodev picture philipodev  ·  3Comments

dsky1990 picture dsky1990  ·  3Comments