docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

Webpack dev server does NOT hot reload (affecting swizzle aliases, prism...)

Open slorber opened this issue 8 months ago • 0 comments

Description

As far as I know, to this day, it is not possible to update Webpack Dev Server config while the dev server is running (https://github.com/webpack/webpack-cli/issues/15)

Unfortunately, we need this for Docusaurus, otherwise there are many situations requiring users to restart the Docusaurus dev server (docusaurus start), notably:

  • docusaurus swizzle modifies Webpack aliases, affecting module resolution (see my comment https://github.com/facebook/docusaurus/pull/10236#issuecomment-2180404988)
  • Adding additional prism syntax highlighting language (see https://github.com/facebook/docusaurus/issues/7913)
  • Any other Docusaurus config change affecting the Webpack config (in particular plugins using configureWebpack)

If no solution is provided by Webpack, we may need to stop/recreate the dev server ourselves in cases we are able to detect. Detecting aliases changes might be the lowest hanging fruit to implement.

Steps to reproduce

Swizzle any component while the dev server is running: the new swizzled copy is added to your site but if you modify it nothing happens. This is because Webpack is still loading the original files. Webpack should load the new swizzled files

Your environment

  • Docusaurus version used: 3.4

Self-service

  • [X] I'd be willing to fix this bug myself.

slorber avatar Jun 20 '24 11:06 slorber