umijs / dumi

📖 Static Site Generator for component library development
https://d.umijs.org
MIT License
3.55k stars 1.17k forks source link

本地插件应该怎么使用 #1879

Closed cangsnage closed 1 year ago

cangsnage commented 1 year ago

Question

想问下本地自己单独写一个插件应该怎么写,怎么使用呢

Sample Code

image 看文档上写直接再plugin的文件写还是文件下写呢。而且不需要再配置么?主要没看懂。有没有实例demo链接。 谢谢

Wxh16144 commented 1 year ago

直接再plugin的文件写还是文件下写呢

都可以,plugin.ts 或者 plugin/my-plugin.ts 都会被加载。

有没有实例demo链接

可以参考我这个:https://github.com/Wxh16144/dumi-debug-app/blob/630ac176f56b9553772c906cbcf8562725419fd8/.dumi/theme/plugin.ts

另外独立 npm 包的 dumi 插件可以参考: https://github.com/Wxh16144/dumi-plugin-color-chunk

cangsnage commented 1 year ago

demo

问下md文件怎么使用这个插件呢

PeachScript commented 1 year ago

没看懂你的问题,需要写插件的具体场景是什么

cangsnage commented 1 year ago

没看懂你的问题,需要写插件的具体场景是什么

就是类似官方的tab切换插件,但是我又没找到这个插件的源码

PeachScript commented 1 year ago

Tab 是约定式的:https://d.umijs.org/guide/page-tab

除非你要注册一个纯 React 写的全局 Tab 才需要用本地插件,参考:https://github.com/umijs/dumi/blob/master/examples/normal/plugin.ts