After building, the css assets paths are wrong.
I'm using cli command for js only:
parcel build src/app.js -d dist
For example, I have this in my SCSS, since my images folder is at my root and my SCSS is under /src/scss:
body {
background-image: url(../../images/bg.png);
}
I imported the SCSS in my app.js like so:
import '/scss/app.scss';
My bg should go into my dist directory and my compiled css should point at bg.png
My bg goes into my dist directory but the compiled css points at /bg.png
(so it search the bg at my root where it isn't).
I guess the issue is in Asset.js at the addURLDependecy function where it adds an extra starting / where it shoudn't but I didn't look further into this.
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.12.3
| Node | 10.15.3
| npm/Yarn | npm 6.4.1
| Operating System | Windows x64
Same here with 1.12.x :(
Same issue all my fonts are broken since the last update
Temp solution: Downgrade parcel to 1.11.0 or 1.10.3
i had the same issue, and could solve it by putting public-url
to .
( parcel build src/app.js -d dist public-url='.'
) looks like parcel now make all assets start with /
inside css if you don't specify public-url property. curious if this helps
@nemisj Thanks, it's works form me with 1.12.3.
"scripts": {
"watch": "parcel ./assets/index.js --public-url ./",
"build": "parcel build ./assets/index.js --public-url ./"
}
i had the same issue, and could solve it by putting
public-url
to.
(parcel build src/app.js -d dist public-url='.'
) looks like parcel now make all assets start with/
inside css if you don't specify public-url property. curious if this helps
This fix the issue, thank you!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.
i had the same issue, and could solve it by putting
public-url
to.
(parcel build src/app.js -d dist public-url='.'
) looks like parcel now make all assets start with/
inside css if you don't specify public-url property. curious if this helps
Is there any explination for this? Seems quite strange to do since hardly anyone puts all their website assets in the root folder.
I'm getting this with v2. Why is it closed?
@artemis-prime Does https://github.com/parcel-bundler/parcel/issues/540 cover your situation? If not, please open a new issue with an example.
yes it does, thanks. I'm too appalled to open anything ;) It's been two years
Most helpful comment
i had the same issue, and could solve it by putting
public-url
to.
(parcel build src/app.js -d dist public-url='.'
) looks like parcel now make all assets start with/
inside css if you don't specify public-url property. curious if this helps