Skip to content

[Bug report] Fail to resolve <img> tag inside a <p> tag when using relative file path #597

@lxb007981

Description

@lxb007981

Bug report

Description

Vite worked well with <img src="./foo.png"> but failed to resolve

<p>
    <img src="./foo.png">
</p>

in the markdown with the error given below:

[vite] Internal server error: Failed to resolve import "./foo.png" from ".vuepress/.temp/pages/index.html.vue". Does the file exist?

Steps to reproduce

Expected behavior

The tag should have been resolved as <img src="@source/foo.png"> in the template but it turned out to be <img src="./foo.png">

Screenshots

vuepress-issue

Environment info

  • Browser:
  • Output of vuepress info:
# Paste output of `vuepress info` here

  System:
    OS: Linux 5.10 Ubuntu 18.04.2 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
    Memory: 8.57 GB / 12.42 GB
    Shell: 4.4.19 - /bin/bash
  Binaries:
    Node: 14.18.1 - /usr/bin/node
    Yarn: 1.22.15 - /usr/bin/yarn
    npm: 8.1.1 - /usr/bin/npm
  Utilities:
    Git: 2.17.1 - /usr/bin/git
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    @vuepress/bundler-vite:  2.0.0-beta.32 
    @vuepress/bundler-webpack: Not Found
    @vuepress/cli:  2.0.0-beta.32 
    @vuepress/client:  2.0.0-beta.32 
    @vuepress/core:  2.0.0-beta.32 
    @vuepress/markdown:  2.0.0-beta.32 
    @vuepress/plugin-active-header-links:  2.0.0-beta.32 
    @vuepress/plugin-back-to-top:  2.0.0-beta.32 
    @vuepress/plugin-container:  2.0.0-beta.32 
    @vuepress/plugin-debug: Not Found
    @vuepress/plugin-docsearch: Not Found
    @vuepress/plugin-external-link-icon:  2.0.0-beta.32 
    @vuepress/plugin-git:  2.0.0-beta.32 
    @vuepress/plugin-google-analytics: Not Found
    @vuepress/plugin-medium-zoom:  2.0.0-beta.32 
    @vuepress/plugin-nprogress:  2.0.0-beta.32 
    @vuepress/plugin-palette:  2.0.0-beta.32 
    @vuepress/plugin-prismjs:  2.0.0-beta.32 
    @vuepress/plugin-pwa: Not Found
    @vuepress/plugin-pwa-popup: Not Found
    @vuepress/plugin-register-components: Not Found
    @vuepress/plugin-search: Not Found
    @vuepress/plugin-shiki: Not Found
    @vuepress/plugin-theme-data:  2.0.0-beta.32 
    @vuepress/plugin-toc: Not Found
    @vuepress/shared:  2.0.0-beta.32 
    @vuepress/theme-default:  2.0.0-beta.32 
    @vuepress/utils:  2.0.0-beta.32 
    vue:  3.2.26 
    vue-loader: Not Found
    vue-router:  4.0.12 
    vuepress: ^2.0.0-beta.32 => 2.0.0-beta.32 
    vuepress-vite:  2.0.0-beta.32 
    vuepress-webpack: Not Found

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions