Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundler path transform in HTML is not being applied #1440

Closed
5 tasks done
citriqa opened this issue Feb 16, 2025 · 2 comments · Fixed by #1443
Closed
5 tasks done

Bundler path transform in HTML is not being applied #1440

citriqa opened this issue Feb 16, 2025 · 2 comments · Fixed by #1443
Labels
pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug

Comments

@citriqa
Copy link

citriqa commented Feb 16, 2025

Describe the bug

In the documentation, it is said that assets can be imported using a path relative to the source root.
In practice, this is not possible.

Reproduction

repro.zip

Steps to reproduce

to recreate attached repro:

  1. pnpm dlx wxt@latest init
  2. choose vanilla and pnpm
  3. pnpm install
  4. alter entrypoints/popup/index.html to set the following as the body content:
    <img src="~/assets/typescript.svg" alt="root alias path"/>
    <img src="../../assets/typescript.svg" alt="relative path"/>

to observe the issue:

  1. pnpm install
  2. pnpm run dev
  3. open popup by clicking on action button
  4. observe the image only displaying once

System Info

System:
    OS: Linux 6.6 cpe:/o:nixos:nixos:24.11 24.11 (Vicuna)
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-1260P
    Memory: 2.53 GB / 15.35 GB
    Container: Yes
    Shell: 5.2.37 - /nix/store/x9d49vaqlrkw97p9ichdwrnbh013kq7z-bash-interactive-5.2p37/bin/bash
  Binaries:
    Node: 23.6.0 - /nix/store/k5zdfljc7gahmdpjjq1y9x8hqs9hxn4g-nodejs-23.6.0/bin/node
    npm: 10.9.2 - /nix/store/k5zdfljc7gahmdpjjq1y9x8hqs9hxn4g-nodejs-23.6.0/bin/npm
    pnpm: 9.15.3 - /nix/store/aik0qrmx9wxy1q480lfwqv1wqsrhcsl8-pnpm-9.15.3/bin/pnpm
  Browsers:
    Chromium: 132.0.6834.110
  npmPackages:
    wxt: ^0.19.13 => 0.19.27

Used Package Manager

pnpm

Validations

@citriqa citriqa added the pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug label Feb 16, 2025
@aiktb
Copy link
Contributor

aiktb commented Feb 16, 2025

https://vite.dev/guide/assets
This seems to be a WXT documentation error, as as far as I know Vite does not support automatic bundling of assets in <img src="...">.

You always need to use import:

<script setup>
import imageUrl from '@/assets/images/logo.svg' // => or relative path
</script>

<template>
  <img :src="imageUrl" alt="img" />
</template>

@aklinker1
Copy link
Collaborator

aklinker1 commented Feb 16, 2025

Can confirm that Vite doesn't support this. I'll update the docs accordingly.

vite-alias-test.zip

Not sure why I thought that was OK when I wrote those docs originally lol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants