通过 .easignore 忽略文件

了解如何配置 EAS 以在构建过程中忽略不必要的文件。


.easignore 文件定义在将项目上传到 EAS 构建 服务器时 EAS 应该忽略哪些文件。

¥A .easignore file defines which files EAS should ignore when uploading your project to the EAS Build servers.

忽略不必要的文件可以帮助减少应用的存档大小和上传时间。

默认情况下,EAS 命令行接口 引用 .gitignore 文件(如果存在)来确定要忽略哪些文件。如果你创建 .easignore 文件,EAS CLI 会将其优先于 .gitignore 文件。创建 .easignore 文件时,请包含 .gitignore 文件中的所有文件和目录,并添加要忽略的其他文件。

¥By default, the EAS CLI refers to the .gitignore file (if it exists) to determine which files to ignore. If you create a .easignore file, the EAS CLI prioritizes it over the .gitignore file. When creating a .easignore file, include all files and directories from your .gitignore file and add additional files you want to ignore.

1

在项目的根目录中创建一个 .easignore 文件。

¥Create a .easignore file in the root of your project.

2

将 .gitignore 文件的内容复制到 .easignore 文件中。然后,添加构建过程中不需要的任何文件。

¥Copy the content of the .gitignore file into the .easignore file. Then, add any files that are unnecessary for the build process.

.easignore
# Copy everything from your .gitignore file here

# Additional ignores specific to EAS builds

# Ignore native directories (if you are using EAS Build)
/android
/ios

# Ignore test coverage reports
/coverage

如果你的项目不包含 android 和 ios 目录,EAS Build 将运行 Prebuild 会在编译之前生成这些原生目录。

¥If your project does not contain android and ios directories, EAS Build will run Prebuild to generate these native directories before compilation.

3

保存文件并触发新构建。

¥Save the file and trigger a new build.

Terminal
eas build --platform ios --profile development

你已成功配置 .easignore 文件。

¥You've successfully configured your .easignore file.