[bug] Resource files are bundled twice in the final application, creating bloat
Describe the bug
Resource files are bundled twice: As an external file AND inline within the executable that launches the application. If a large file is set as a resource, this causes the built application to balloon in size.
Reproduction
Set any large file as a resource in tauri.config.json > tauri > bundle > resources and build it using npm run tauri build.
Expected behavior
I would expect a file that is set as a resource, and therefore preserved as an external (separate) file, is only bundled once in the final application.
Full tauri info output
[✔] Environment
- OS: Windows 10.0.22631 X64
✔ WebView2: 126.0.2592.68
✔ MSVC:
- Visual Studio Build Tools 2022
- Visual Studio Community 2022
✔ rustc: 1.73.0 (cc66ad468 2023-10-03)
✔ cargo: 1.73.0 (9c4383fb5 2023-08-26)
✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 18.17.1
- npm: 10.8.0
[-] Packages
- tauri [RUST]: 1.6.1
- tauri-build [RUST]: 1.5.1
- wry [RUST]: 0.24.7
- tao [RUST]: 0.16.7
- @tauri-apps/api [NPM]: 1.5.3 (outdated, latest: 1.5.6)
- @tauri-apps/cli [NPM]: 1.5.11 (outdated, latest: 1.5.14)
[-] App
- build-type: bundle
- CSP: unset
- distDir: ../build
- devPath: http://localhost:5173/
- framework: Svelte
- bundler: Vite
Stack trace
No response
Additional context
In my case, I have a 1GB file that needs to be accessed using absolute paths, and I therefore cannot do so if it is bundled inline in the executable. But if I set this file as a resource in tauri.config.json, it is bundled twice in the final application, causing its size to balloon unnecessarily. How can I prevent this from happening? And if I can't, how can I reference the same file if it is bundled inline?
Resources are never bundled inside the application, we only bundle the files inside your distDir which is the frontend assets and should be fairly small. Could you please show a minimal repro?
Here is my minimal repro: https://github.com/Sidders22/tauri-resource-issue
looking at your repro, you seem to be using SvelteKit and putting your resources inside the static folder which will be bundled into the dist folder, hence it will be included in your binary. And you also specified it in your tauri resources configuration, hence the double resource issue. You'll need to remove the resources from one place or the other.
Thank you for following up on this. I reconfigured my project as you suggested and moving the file from the static folder solved my issue.