core
core copied to clipboard
feat(core): add hook before initialize
This adds a lifecycle hook before the app is initialized. I'm not sure if you want this implemented,
I want to change/update locale data through a plugin, but I noticed the changes are not being reflected in the pages array in other plugins. I checked out the source and discovered this is because the earliest hook, onInitialized happens after pages are resolved. So I added another hook right before it.
I've updated the unit tests and tested it with my use case and it works like a charm.
I'm not sure if it is necessary because we can do things in plugin before initialization via "PluginFunction":
const fooPlugin = (app) => {
// here we can do things just like beforeInitialize
return {
name: 'vuepress-plugin-foo',
onInitialized(app) { /* ... */ }
}
}
@meteorlxy Wow, I blame tunnel vision. If having this as a hook doesn't have any other advantages this can be closed. :) Thanks