Skip to content

How to resolve an asset path when using HTML template in JavaScript #18

@hqw567

Description

@hqw567

Current behaviour

The relative paths of src files in HTML templates cannot be resolved correctly in JavaScript.

const aiHtml = `
<img
  class="w-7 h-7 sm:w-10 sm:h-10 rounded-full mr-2 sm:mr-4 shrink-0"
  src="../../../assets/images/chat-ai.png"
  alt="" />
`;

// or
const aiHtml = `
<img
  class="w-7 h-7 sm:w-10 sm:h-10 rounded-full mr-2 sm:mr-4 shrink-0"
  src="@images/chat-ai.png"
  alt="" />
`;

Environment

  • OS: Windows
  • version of Node.js: 18.16.0
  • version of Webpack: 5.87.0
  • version of the Plugin: 1.18.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions