Based on the information provided in the knowledge sources, I don't have specific details about deploying static Next.js apps to AWS S3 using the nx tool. However, I can provide some general guidance on deploying static Next.js apps to AWS S3.
When deploying static Next.js apps to AWS S3, you typically need to upload all the files generated in the build output directory (in your case, the dist folder) to the S3 bucket. This includes HTML, CSS, JavaScript, and any other assets required by your application.
Your command for syncing the dist folder to the S3 bucket looks correct. Here is a breakdown of the commands you provided:
-
Syncing the build output to the S3 bucket:
aws s3 sync ./dist/apps/mfe1 s3://${{ env.AWS_S3_BUCKET }}/core --region ${{ secrets.AWS_REGION }} --delete
This command uploads the contents of the ./dist/apps/mfe1 directory to the specified S3 bucket and path (s3://${{ env.AWS_S3_BUCKET }}/core). The --delete flag ensures that any files in the S3 bucket that are not present in the dist directory are removed.
-
Creating a CloudFront invalidation:
aws cloudfront create-invalidation --distribution-id ${{ env.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/mfe1/*"
This command creates an invalidation for the specified CloudFront distribution, ensuring that the cached content is refreshed with the new files you just uploaded.
If you need more detailed instructions or run into specific issues, you might want to refer to the AWS documentation or the Next.js documentation for deploying static sites.