Search code examples
javascriptnpmparceljs

ParcelJs add extra "/" before all files link


I'm actually working on a ts project with ParcelJs. When I build my project and open it on the ParcelJs server on http://localhost:1234/ everything work great. But when I try to open it outside this server all my files are not found because there is an extra / at the beginning of each file link.

For example ParcelJs give in my index.html links like this that do not work:

<script src="/src.4254afb6.js"></script>

But when I remove this / like this everything is working as expected:

<script src="src.4254afb6.js"></script>

So what have I to do to fix it ?


Solution

  • To make all links relative (with no /) you will need to add an extra parameter --public-url with the value ./ when you run ParcelJs like this :

    parcel index.html --public-url ./