Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
We have discussed a lot about the plugin: the long discussion & vote, and these awesome PRs: #196 and #216,
But when I start to develop plugin at many different situations, I find that the really appropriate plugin mechanism must delay the timing of execution. i.e. we need to support
life cycle
to let plugin developers to be able to do what they want to do at the right moment.In order to better describe the PR, I drew these two pictures.
vuepress dev
vuepress build
As shown above, and as we discussed earlier, if we just execute all the plugins at the end of the
prepare
, then once a plugin has written some files to outDir, then you will never see it, which is too bad.So for now, a plugin would be like this:
What are the benefits of doing so? for example, if we make the internal log at a default hook handler when we detect there is no other hook handlers, you can override it via plugins, so there would born a separate very handsome plugin.
Of course, It's still worth discussing how to make it better, feel free to give your thoughts.
Thanks~