When using --preload-file in the Emscripten target linker arguments, the toolchain will generate a file called crate-name.data containing the specified files to serve alongside the .js and .wasm files. However, cargo web doesn't seem to be aware of this as it only copies the .js and .wasm to the output directory, and the .data file is effectively missing when using cargo web start or cargo web deploy. The .data file is left within deps/ and while you can copy it into static/ as a workaround, it is easy to end up with a stale version of this file, which can cause problems if the generated .js file is newer than the .data file (since the .js file contains the offsets into the .data file for each virtual file).
When using
--preload-file
in the Emscripten target linker arguments, the toolchain will generate a file calledcrate-name.data
containing the specified files to serve alongside the .js and .wasm files. However, cargo web doesn't seem to be aware of this as it only copies the .js and .wasm to the output directory, and the .data file is effectively missing when usingcargo web start
orcargo web deploy
. The .data file is left within deps/ and while you can copy it into static/ as a workaround, it is easy to end up with a stale version of this file, which can cause problems if the generated .js file is newer than the .data file (since the .js file contains the offsets into the .data file for each virtual file).