dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

dx serve shouldn't clear the target build directory.

Open sbant opened this issue 1 year ago • 3 comments

Problem

When use new version of dioxus-cli ( 0.6.0-alpha.5 ) in Windows, run dx serve clear the target directory everytime.

My program need some dlls and config files.

Expected behavior

Just overwrite the build output like old version.

Environment:

  • Dioxus version: 0.6.0-alpha.5
  • OS info: Windows 11
  • App platform: desktop

sbant avatar Nov 16 '24 19:11 sbant

I tried edit "dioxus/blob/main/packages/cli/src/build/request.rs"

comment line 571 _ = remove_dir_all(self.exe_dir()); to //_ = remove_dir_all(self.exe_dir());

I'm not sure this is the right approach, but this make my program recompile, hot reload and run all successful.

sbant avatar Nov 28 '24 11:11 sbant

We need to clear the build folders on rebuilds as some items such as old assets won't be deleted and may be unintentionally used. I have also heard that overwriting has caused corruption issues in the past though I'm unfamiliar with that.

For moving DLLs, you should generally be using a build.rs that copies the DLLs to the location you need them.

DogeDark avatar Nov 29 '24 21:11 DogeDark

I think use build.rs, copy DLLs and config files everytime before rebuild is not a good solution.

The program config maybe changed during running and save to files, as current dioxus-cli clear entire directory, if those config files not saved to another location, and suddenly rebuild in dioxus-cli, then all config files loss.

dioxus cli also does not have some way to do post build task.

If there must some old assets need to be cleared, then user can also use build.rs to clear them.

Additionaly, dx serve is for development. I think it's right dx bundle clear the target directory, but not dx serve

sbant avatar Nov 30 '24 15:11 sbant

We're choosing to clear our own build dir to ensure everyone is running from a "fresh" directory and no garbage is left behind that breaks determinism.

I recommend using the asset!() macro for copying DLLs and config files into your app. You can read and load these at runtime.

jkelleyrtp avatar Jan 09 '25 00:01 jkelleyrtp