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

feat: restart server with overwritten configuration #8766

Closed
wants to merge 1 commit into from

Conversation

CHOYSEN
Copy link
Contributor

@CHOYSEN CHOYSEN commented Jun 24, 2022

Description

Provide a programming way to modify configuration like base/port.

Additional context

HAS BREAKING CHANGE!

Remove the forceOptimize arg, so user need manually pass { server: { force: true } } to keep the previous behavior


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@netlify
Copy link

netlify bot commented Jun 24, 2022

Deploy Preview for vite-docs-main ready!

Name Link
🔨 Latest commit a1b6050
🔍 Latest deploy log https://app.netlify.com/sites/vite-docs-main/deploys/62b5c81214412e00089e920d
😎 Deploy Preview https://deploy-preview-8766--vite-docs-main.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@bluwy
Copy link
Member

bluwy commented Jun 24, 2022

Is there an example of a usecase for restarting with a different base / port? forceOptimize was initially added for vite-plugin-svelte's prebundleSvelteLibraries option (IIRC), but we don't use it now as there's a different way of handling it. And I'm not sure if there's anyone else using it 🤔

@CHOYSEN
Copy link
Contributor Author

CHOYSEN commented Jun 24, 2022

Vitepress allow user write their config, and then listening the config change.

Though i can write the following code to modify base and restart server, but it will be better to provide a explicit way.

server.config.inlineConfig.base = newData.base
await server.restart()

@bluwy
Copy link
Member

bluwy commented Jun 24, 2022

Shouldn't restarting the server would re-run all plugins which can then set the new base option? So perhaps for this code we can have the vitepress plugin set the base root etc in the config hook which should fix the issue. Otherwise, it'd have to restart the wrapping vitepress server instead.

While I think we're working around this when it can be as simple as the proposed solution in the PR, I think it would be better in the long run when more plugins call restart themselves, and we don't have these temporary state potentially dangling.

@CHOYSEN
Copy link
Contributor Author

CHOYSEN commented Jul 3, 2022

Thanks for your reply, i agree with you that plugin should use the config hook to overwrite config. And do you think we should remove forceOptimize(as a breaking change in V3)?

@CHOYSEN CHOYSEN closed this Jul 3, 2022
@bluwy
Copy link
Member

bluwy commented Jul 3, 2022

And do you think we should remove forceOptimize(as a breaking change in V3)?

I think we could leave it in for awhile if someone is actually using it. The other way of handling things may not be as straightforward for them, but until we have something like server.queueOptimizerRerun or similar, I think then we can remove it. That way we can call the function anywhere we like, instead of only when restarting the server.

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

Successfully merging this pull request may close these issues.

None yet

2 participants