Skip to main content

is there away to convert the relative path for image to a local host URL using parcel?

I 'm using parcel to bundle my project, the src attribute need to be converted from relative path to local host path

by parcel.

so I 'm looking for a solution for this problem.

class SectionResoursesView {
  generateMarkup(data) {
    let markup = ``;

    data.map(res => {
      markup += `
        <div class="col-4">
            <div class="resource">
                <a href="${res.url}" target="_blank" class="resource__link" >
                    <img src="../img/logos/codepen.png" alt="${res.logo.alt}" class="resource__image" />
                    <span class="resource__title">${res.name}</span>
                </a>
            </div>
        </div>
      `;
    });

    return markup;
  }
}

export default new SectionResoursesView();

I expected that I can find away to achieve this problem, and I can convert relative path ***../img/logos/codepen.png *** to local host path http://localhost:1234/codepen.e63af648.png?1675016957052

Via Active questions tagged javascript - Stack Overflow https://ift.tt/FTH1t2w

Comments