Reducing the size of Unreal Engine 5 source project
When you decide to compile Unreal Engine 5 yourself, you might notice that the initial project is enormous. This is because you are downloading content for many platforms that you might not even need. Luckily, there is an easy way to reduce that size while remaining fully able to work with the engine.
When we clone the repository, the engine's source is about 2.48GB (measured for version 5.7.4). Not bad! However, once we run Setup.bat to download additional dependencies, the size increases to a whopping 82.9GB!
This happens because the script downloads extra files for every supported platform and localization files for many languages. These files are huge.
Excluding Platforms via Setup.bat
Let’s assume we want to make a game for Windows only. We aren't interested in the files required by other platforms. We can skip downloading them by passing extra arguments to Setup.bat.
Create a new batch file - let's call it SetupWindowsOnly.bat - and add the following command:
Setup.bat -exclude=WinArm64 -exclude=Unix -exclude=Linux -exclude=LinuxArm64 -exclude=Mac -exclude=Android -exclude=IOS -exclude=TVOS -exclude=HoloLens -exclude=VisionOS
With just this change, we've already reduced the download size to 54.7GB!
Fine-Tuning with .gitdepsignore
But wait, there’s more! You can create a .gitdepsignore (with a dot at the beginning!) file in the same directory as Setup.bat to specify exactly which files you don't need.
1. Localization Files
If you plan to work in English and don't need the engine localized into other languages, add the following lines to your .gitdepsignore file to ignore all languages except English:
/Engine/Content/Localization/
!/Engine/Content/Localization/**/en/*
2. DotNet Binaries
Another big chunk of unnecessary files are the DotNet binaries for other platforms. Even though we told Setup.bat to exclude those platforms, some files are still downloaded. To get rid of them, add these lines to .gitdepsignore:
/Engine/Binaries/ThirdParty/DotNet/
!/Engine/Binaries/ThirdParty/DotNet/**/win-x64/
3. Third-Party Directories
There are still many files, mostly in the ThirdParty directories, that are required for other platforms. I ran a script on a fully downloaded engine source to find all directories containing keywords like unix, linux, arm64, and macos.
- Script to find keywords: https://gist.github.com/zompi2/90b996004ad5b555666ae3a7ad582fd0
- My full .gitdepsignore: https://gist.github.com/zompi2/42f17a61ae327b65b42ea5aef91d35df
With all of these tweaks applied, the size drops to just 33.8GB!
What’s Next?
At this point, we can't exclude much else without sacrificing engine functionality. From here, it’s up to you. I use SpaceSniffer to check which parts of the engine take up the most space. For example, the MetaHuman plugin and its content take about 7.24GB. If you don't plan to use MetaHumans, that is a lot of unnecessary data to store.
As you can see, it is fairly easy to determine which parts of Unreal Engine you want to keep. Let's not waste disk space on things we don't need!
Hope this helps. Cheers! <3