AWS Amplify 构建过程中的缓存工件是什么?

What is the Cache Artifact in AWS Amplify's build process?

使用 AWS Amplify 构建 React 项目时,构建过程中有一个点会创建缓存工件。这是什么?

我遇到了一个问题,它的大小可能会增长到数 GB,并导致构建过程超时。例如,一个 1 分钟的本地构建可能需要 30 分钟的放大,并且几乎所有时间都花在了 Creating cache artifact 步骤上。

这是 Amplify 构建日志的片段:

2019-10-18T17:51:29.865Z [INFO]: ## Build completed successfully
2019-10-18T17:51:29.867Z [INFO]: # Starting caching...
2019-10-18T17:51:29.968Z [INFO]: Creating cache artifact...
2019-10-18T17:52:10.152Z [INFO]: # Cache artifact is: 318MB
2019-10-18T17:52:10.265Z [INFO]: # Uploading cache artifact...
2019-10-18T17:52:13.617Z [INFO]: # Caching completed

这是您可能配置的文件缓存。保存文件以缩短构建时间,因为不必每次都转到源文件。例如,缓存 node_modules:

这是在amplify.yml中配置的。

version: 0.1
backend:
  ...
frontend:
  ...
  cache:
    paths:
      - node_modules/**/*