VS Code React Native代码片段扩展:README.md图片显示问题求助
遇到的错误提示:
ERROR Couldn't detect the repository where this extension is published. The image '/images/SnippetDemo1.png' will be broken in README.md. GitHub/GitLab repositories will be automatically detected. Otherwise, please provide the repository URL in package.json or use the --baseContentUrl and --baseImagesUrl options.
以下是三种可行的解决方法:
在package.json中配置仓库地址
打开扩展根目录的package.json,添加repository字段,示例配置:{ "repository": { "type": "git", "url": "https://github.com/你的用户名/你的扩展仓库名.git" } }配置完成后,Marketplace会自动基于仓库地址解析图片相对路径,原有的
写法即可正常显示图片。使用图片的绝对URL引用
将图片上传到GitHub仓库后,复制图片的原始文件链接(比如GitHub上点击图片的「Raw」按钮获取),直接替换相对路径,示例:注意替换链接中的用户名、仓库名和分支名称(如main、master)。
打包时指定baseImagesUrl参数
使用vsce工具打包扩展时,通过--baseImagesUrl参数指定图片的基础URL,示例命令:vsce package --baseImagesUrl https://raw.githubusercontent.com/你的用户名/你的扩展仓库名/main/images/这样README里的相对路径会自动拼接这个基础URL,无需修改原有图片引用代码。
内容的提问来源于stack exchange,提问作者Jatin Bhuva

