From e51382e331e4256387f5ff0b485cba1122dfd8a3 Mon Sep 17 00:00:00 2001 From: Ldoppea Date: Mon, 13 Jan 2025 18:08:28 +0100 Subject: [PATCH] fix: Disable `fastRefresh` in shared Rsbuild configuration In our projects, we found that using `rsbuild build --watch --mode development` instead of just `rsbuild build --watch` would speed up the re-build process But when doing so, the bundler enables the [fastRefresh](https://rsbuild.dev/plugins/list/plugin-react#fastrefresh) mode from plugin-react This mode does not work on `build` mode and trying to run the cozy-apps would produce a blank screen with some `$RefreshSig$ is not defined` This is because fastRefresh is meant to be run with `rsbuild dev` command So we want to disable this mode for all commands but `rsbuild dev` --- config/rsbuild-config-cozy-app/getRsbuildConfig.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/rsbuild-config-cozy-app/getRsbuildConfig.js b/config/rsbuild-config-cozy-app/getRsbuildConfig.js index d16925a37f..16614aef42 100644 --- a/config/rsbuild-config-cozy-app/getRsbuildConfig.js +++ b/config/rsbuild-config-cozy-app/getRsbuildConfig.js @@ -31,7 +31,9 @@ function getRsbuildConfig({ plugins: [ pluginEjs(), pluginNodePolyfill(), - pluginReact(), + pluginReact({ + fastRefresh: import.meta.env.NODE_ENV === 'development' + }), pluginStylus({ stylusOptions: { // To resolve import from cozy-ui inside stylus files