Closed ghost closed 5 years ago
Sure, I forked that repo so you can see a working implementation and the specific changes
Essentially, there's two things you need to do.. firstly require the component, which is straight forward enough, and secondly patch the metalsmith instance. This part is unusual amongst metalsmith plugins because the syntax is component(metalsmith)
instead of the way other components work like metalsmith.use(component())
I notice that with my fork, all the plugin names are listed as "demo". That's pretty much a bug to do with the difficulties detecting plugin names, and it's occurring because the package name starts with metalsmith-
. If the package name didn't start with that, then the plugin names would be detected more reliably.
Perfect. This is exactly what I needed!
Is there a way I can "rename" the packages so metalsmith-debug-ui can reliably detect plugin names?
I've pushed a new version which hopefully fixes this problem without creating any new problems. you can install with npm install --save metalsmith-debug-ui@0.3.2
It's difficult to explain but when plugins are passed to metalsmith they're "anonymous", so showing the plugin name in debug-ui requires a bit of a hack (looking at the stack trace). It's never going to work every time, but if it works most of the time then that's enough to navigate around the different steps in the build process.
Presently, when I run this with the metalsmith-demo repo I get correct names for 10 of the 13 plugins. The other three are something to do with metalsmith-collections, it's not possible to fix them.
As an aside, or for others reading this, the component also provides a report
function which is a potential workaround for this issue.
Closing because I think this might be resolved. Feel free to re-open or continue commenting.
Very much appreciate this additional info. THANK YOU!
I am new to metalsmith. I am trying inject your tool into a metalsmith sample I found (https://github.com/craigbuckler/metalsmith-demo). But the syntax here in the ReadMe does not look like that in the example I am using or in any documentation I see on the Metalsmith site. Can you tell me how to use your tool with this example build.js? Thx
build.js.txt