vitepress icon indicating copy to clipboard operation
vitepress copied to clipboard

静态资源解析打包的时候报错

Open joisun opened this issue 1 year ago • 3 comments

Describe the bug

像 下面这样的资源路径在打包的时候报错 “Error: [vite]: Rollup failed to resolve import "09_Java 语法.assets/image-20210630002730821.png" from "/home/jayce/workspace_personal/learn-content/contents/java-kuangshen_learn/09_Java 语法.md".”

 ![image-20210630003516350](09_Java 语法.assets/image-20210630003516350.png)

必须换成

[image-20210630003516350](./09_Java 语法.assets/image-20210630003516350.png)

太多了换起来好麻烦

Reproduction

Expected behavior

希望能支持像 [image-20210630003516350](09_Java 语法.assets/image-20210630003516350.png) 这种资源引入方式, 或者支持正则配置

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (12) x64 Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz
    Memory: 13.57 GB / 15.54 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
    pnpm: 8.7.1 - /usr/local/bin/pnpm
  npmPackages:
    vitepress: 1.0.0-rc.31 => 1.0.0-rc.31

Additional context

No response

Validations

joisun avatar Dec 06 '23 07:12 joisun

  • 这个你自己处理下啊,这是 Node.js 的规则,和 vitepress 无关,并且路径不要用中文。
  • 如果你用的是 Typora ,那么可以这么设置: image
  • 这样,你可以截图的时候,直接在 markdown 文档里面复制即可,会自动帮你粘贴到对应的目录中。

Aurorxa avatar Dec 20 '23 04:12 Aurorxa

Cannot reproduce this on macOS.

On macOS, ![Image](09_Java 语法.assets/image-20210630003516350.png) won't be parsed as an image for there is a blank space.

But ![Image](09_Java%20语法.assets/image-20210630003516350.png) and ![Image](./09_Java%20语法.assets/image-20210630003516350.png) both work fine.

No errors occur when vitepress build in all cases above.

Octobug avatar Jan 08 '24 14:01 Octobug

won't be parsed as an image for there is a blank space

Yeah, that's compliant with commonmark spec. You can either manually percent encode it (to %20) or use angular brackets - ![image-20210630003516350](<09_Java 语法.assets/image-20210630003516350.png>) - Both seem to be working fine for me. But anyway parsing errors shouldn't give that error unless that file doesn't actually exist.

并且路径不要用中文

This is also not an issue. You can use non-ascii characters just fine as long as they are permitted by your OS.

brc-dd avatar Jan 08 '24 14:01 brc-dd

自己整个图床,不好么

yangdong520 avatar Apr 10 '24 21:04 yangdong520

@yangdong520 可能觉得图床会宕机吧

Aurorxa avatar Apr 10 '24 22:04 Aurorxa

@yangdong520 可能觉得图床会宕机吧

不能这么想,那放在本地,磁盘还会损坏呢,能工提升自己生产力的东西,能用坚决用,省下来时间不是又可以多敲几行代码了么

yangdong520 avatar Apr 12 '24 01:04 yangdong520

Off topic, closing for now.

awxiaoxian2020 avatar Apr 12 '24 11:04 awxiaoxian2020