这个 Vite 插件,能让你通过点击控制台中的 console.log 打印信息跳转到编辑器

191 天前
 lyc575757

主要功能

  1. 根据不同的文件类型高亮输出 console.log 所在的文件名,行数,变量名
  2. 通过点击跳转到编辑器对应的 console.log 所在行

效果展示

使用方法

# npm
npm install -D vite-plugin-turbo-console
# yarn
yarn add -D vite-plugin-turbo-console
# pnpm
pnpm i -D vite-plugin-turbo-console
import { defineConfig } from "vite";
import TurboConsole from "vite-plugin-turbo-console";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [TurboConsole({
    /* options here */
  })],
});

GitHub 仓库

欢迎大家使用并反馈

2237 次点击
所在节点    分享创造
35 条回复
NickyXing
191 天前
这个确实强
HoseaDev
191 天前
这个有点强。
qizhiyuan
191 天前
这个确实有点强。
zhw2590582
191 天前
有点意思
lizhenda
191 天前
准备试试,有点意思
ZGame
191 天前
好活!
chanChristin
191 天前
我记得之前有个插件可以在页面上点击跳转到编辑器对应位置,也支持 webstorm ,有没有大佬知道是哪个。
lyc575757
191 天前
chanChristin
191 天前
@lyc575757 应该不是,我记得是个浏览器插件,不需要修改代码,当时还想要装一下,结果就忘记是哪个了。
luchenwei9266
191 天前
666666
caocong
191 天前
在我的 react 项目里用了一下,点击后新开窗口跳转到 http://localhost:3000/__tc/i.html?f=src/.....报 404 错误,这个__tc/i.html 是我的使用方式不对吗,需要起什么服务么
caocong
191 天前
找到原因了,我 vite 设置了 base: '/xxxx/',点击的跳转地址是 http://localhost:3000/xxxx/__tc/i.html ,手动改成 http://localhost:3000/__tc/i.html 是可以跳转到编辑器的
lyc575757
191 天前
@caocong #12 我修复一下
lyc575757
191 天前
@caocong #12 升级到最新版本试一下,应该已经修复了
caocong
191 天前
@lyc575757 vscode 可以用了,webstorm 跳转时报错了
```
Could not open index.tsx in the editor.
The editor process exited with an error: spawn /Applications/WebStorm.app/Contents/MacOS/webstorm ENOENT.
```
另外有个个人习惯的问题,跳转过去光标位置是在代码前空一格的位置,紧贴 console.log()前面或者后面都感觉好些
lyc575757
191 天前
@caocong #15
跳转报错应该是上游依赖的问题,可以尝试一下这个解决方法
https://github.com/yyx990803/launch-editor/issues/9#issuecomment-874352139

第二个我优化一下
tianzi123
191 天前
有个报错 为啥用了这个差件就不能打印 error,否则项目无法正常显示
enchilada2020
190 天前
哇 舒适
enchilada2020
190 天前
@tianzi123 问一下 在变量后面提示类型的是啥插件
nightmare233
190 天前
这个确实 c

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/987775

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX