Skip to content

Issue with Referencing dist Files Between Packages in Amplify Deployment

0

I am currently deploying a frontend project using AWS Amplify, and the deployment scripts are defined in amplify.yml.

I am encountering an issue during the build process and would like your assistance. The folder structure involved is as follows:

packages/packA packages/packB The desired behavior is for packages/packB to reference the dist files built in packages/packA. While this works correctly in the local environment, in the Amplify deployment environment, packages/packB fails to reference the dist files from packages/packA.

Additionally, the project uses a Yarn Workspace setup. I would appreciate any guidance or suggestions on how to resolve this issue in the Amplify environment.

asked 2 years ago186 views

1 Answer
0

This issue you're experiencing with referencing dist files between packages in your AWS Amplify deployment is not uncommon, especially when working with monorepo setups like Yarn Workspaces. Amplify does support monorepo configurations, including those using Yarn Workspaces, but there might be a few things you can check to resolve the problem:

  1. Build Order: Ensure that your amplify.yml file specifies the correct build order. Make sure packA is built before packB, so the dist files are available when packB needs them.

  2. Workspace Configuration: Verify that your Yarn Workspace is correctly set up in the root package.json file, and that Amplify recognizes it.

  3. Relative Paths: Check that the references from packB to packA's dist files use the correct relative paths. The paths that work locally might need adjustment in the Amplify environment.

  4. Amplify Build Settings: Review your Amplify build settings to ensure they're configured to handle your monorepo structure correctly. You might need to adjust the base directory or build commands.

  5. Custom Build Scripts: Consider creating custom build scripts that explicitly copy the necessary dist files from packA to where packB expects them, as part of your build process.

  6. Environment Variables: If you're using environment-specific paths, make sure these are correctly set in your Amplify environment.

  7. Caching: If you're using build caching in Amplify, try clearing the cache to ensure you're working with a fresh build.

If these steps don't resolve the issue, you might need to examine your build logs in detail to identify at which point the reference is failing. Remember that Amplify creates a temporary compute container for each build, so the environment might differ slightly from your local setup.

Amplify's flexibility in supporting various repository configurations, including monorepos with tools like Yarn Workspaces, should allow you to resolve this with the right configuration. If the problem persists, you may need to reach out to AWS support for more specific guidance tailored to your project structure.

Sources
New in AWS Amplify: Expanded Fullstack Deployment Capabilities for Teams of All Sizes | Front-End Web & Mobile
AWS Amplify | Extensible Web & Mobile Apps | Amazon Web Services

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.