docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

postStart plugin lifecycle

Open gabrielcsapo opened this issue 3 years ago • 2 comments

Have you read the Contributing Guidelines on issues?

Description

Implement postStart which is called when the dev server has finished starting. This is similar to postBuild but the dev server version.

Has this been requested on Canny?

No response

Motivation

Discussion is ongoing on what the functionality would be https://github.com/facebook/docusaurus/discussions/5616. Here is an implementation at postCompile https://github.com/facebook/docusaurus/pull/7737#issuecomment-1179482628.

https://docusaurus.io/docs/next/api/plugin-methods outlines that postStart is TBD.

Screen Shot 2022-07-08 at 10 30 15 PM

API design

No response

Have you tried building it?

No response

Self-service

  • [X] I'd be willing to contribute this feature to Docusaurus myself.

gabrielcsapo avatar Jul 09 '22 05:07 gabrielcsapo

This seems like the best place to implement it, given that this is utilized by openBrowser which is called once.

https://github.com/facebook/docusaurus/blob/main/packages/docusaurus/src/commands/start.ts#L238-L243

  const devServer = new WebpackDevServer(devServerConfig, compiler);
  devServer.startCallback(() => {
    if (cliOptions.open) {
      openBrowser(openUrl);
    }
  });

gabrielcsapo avatar Jul 09 '22 05:07 gabrielcsapo

I tried to implement the postStart hook as you suggested @Josh-Cena in https://github.com/facebook/docusaurus/pull/7751. Let me know if I can do anything else to help out. Really appreciate all the work you all do!

gabrielcsapo avatar Jul 09 '22 05:07 gabrielcsapo

Closing issue related to closed PR: https://github.com/facebook/docusaurus/pull/7751

If someone come up with a strong use case for postStart we can revisit

slorber avatar Sep 25 '23 16:09 slorber