通过 .easignore 忽略文件

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


.easignore 文件定义了在将项目上传到 EAS Build 服务器时,哪些文件应被 EAS 忽略。

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

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

默认情况下,EAS CLI 会参考 .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 # Ignore files and directories that EAS Build doesn't need to build your app /docs # Ignore native directories (if you are using EAS Build) /android /ios # Ignore test coverage reports /coverage

如果你的项目不包含 androidios 目录,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.

使用 .easignore 将文件添加到你的项目上传

🌐 Adding files to your project upload with .easignore

除了忽略 gitignore 文件中未列出的其他文件外,你还可以使用 .easignore 文件将未提交到源代码管理的文件包含在 EAS Build 上传中。如果你有自定义脚本生成在构建之前需要的临时文件,这将非常有用。要将未在源代码管理中的文件上传到 EAS Build,请在 .easignore 文件中使用 ! 前缀添加它,同时包含 .gitignore 中的其他内容。带有 ! 前缀的文件应放在最后,这样它就会优先于之前的任何忽略规则。

🌐 In addition to ignoring additional files beyond what is in your gitignore file, you can also use the .easignore file to include files with your EAS Build upload that are not committed to source control. This is useful if you have custom scripts that generate temporary files needed for your build process just before the build. To upload a file not in source control to EAS Build, add it to the .easignore file with a ! prefix, along with the rest of your .gitignore contents. The ! prefixed file should be last, so it takes precedence over any prior rules that would ignore it.

.easignore
# Copy everything from your .gitignore file here /android /ios # Include a file not in source control !temp_file.json