reactjsaws-amplify

Should amplify_outputs.json be git ignored?


I have an amplify project in React and I set up the front end pages already using React-Router etc.. and deployed on amplify and it was working great.

Now I want to add a backend so I ran:

npm create amplify@latest

it creates an amplify folder and creates amplify_outputs.json locally but when I try and deploy the latest commit I am getting a build error:

2024-10-03T15:49:01.443Z [INFO]: src/App.tsx(10,21): error TS2307: Cannot find module '../amplify_outputs.json' or its corresponding type declarations.

I see that amplify_outputs.json was added to the git ignore automatically but its not getting generated on the build so was wondering if I should remove it from the git ignore but it has a user_pool_client_id in it so Im pretty sure its supposed be generated on the build.


Solution

  • Hi I did have to add a amplify.yaml but through different testing this is what I needed:

    version: 1
    backend:
      phases:
        build:
          commands:
            - npm ci --cache .npm --prefer-offline
            - npx ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID
    frontend:
      phases:
        build:
          commands:
            - npm run build
      artifacts:
        baseDirectory: dist
        files:
          - '**/*'
      cache:
        paths:
          - .npm/**/*
          - node_modules/**/*
    

    Here is the link for this: https://docs.amplify.aws/react/deploy-and-host/fullstack-branching/mono-and-multi-repos/