Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a server option to get a reference to the dev server when ready #17

Open
genemars opened this issue Mar 14, 2022 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@genemars
Copy link

It can be useful in some circumstances to get a reference to the HTTP server in order to be able to programmatically request a client refresh.
Maybe something like:

eleventyConfig.setServerOptions({
    ....
    ready: (ds) => {
        initCustomWatcher(eleventyConfig, ds);
    }
    ....
}

and then somewhere else: ds.sendUpdateNotification(...).

@zachleat zachleat added the enhancement New feature or request label Mar 14, 2022
@j-f1
Copy link

j-f1 commented Apr 26, 2022

I would like this functionality because I want to build my website to a PDF using Puppeteer. That only works properly when the website is served by a server (rather than with a file: URL). Previously, here’s what I did:

eleventyConfig.setBrowserSyncConfig({
  snippet: false,
  callbacks: {
    async ready(err, bs) {
      port = bs.server.address().port;
      await (
        await renderPDF
      )(port);
      if (process.env.BAND_BOOK_ONESHOT) {
        // stop the server immediately when running `npm run build`
        process.exit(0);
      }
    },
  },
});

source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants