I want to learn writing plugins for gitbook (because I want to use it and will need custom plugins).
However, I feel documentation is a bit sparse on the matter, and reading code from existing plugins doesn't help me very much in this question:
How can I test a plugin before publishing it. The documentation gives some hints on how the plugin has to look, and then it tells me to publish it.
Of course I don't want to do that yet, I want to develop and test it locally before publishing. But I don't see how that can be done.
I tried to copy an installed plugin inside /usr/lib/node_modules/gitbook-cli/node_modules/
to create my new plugin, but when I try to use the plugin in a book I get error message telling me to install the plugin through npm
.
Is there a way to use a plugin (for testing or maybe generally) without first publishing it on npm?
This is not a definitive answer (so I won't "accept" it), but a workaround I found, which can be acceptable, depending on the circumstance.
What is possible is:
book.json
gitbook install
in the book's directoryThis will download and install the plugin inside the book's
node_module
directory. Modifying the JavaScript files there will take effect on subsequent gitbook builds. So you can continue developing your plugin locally.What has to be seen is how (if) that modified plugin can be published, once it's ready.
And it may be considered a (more or less severe) drawback that you now have a completely unpresentable plugin published on npm.