通过 .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
Create a .easignore file in the root of your project.
2
Copy the content of the .gitignore file into the .easignore file. Then, add any files that are unnecessary for the build process.
# 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
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.
-
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.
# Copy everything from your .gitignore file here
/android
/ios
# Include a file not in source control
!temp_file.json