Reputation: 1
I try to follow this documentation: https://docs.amplify.aws/react/deploy-and-host/fullstack-branching/monorepos/
These are the command I used to create Nx workspaces
npx create-nx-workspace@latest
npm install –save-dev @nx/react
npm install –save-dev @nx/react-native
nx generate @nx/react:app apps/web-app
nx generate @nx/react:app apps/mobile-app
Then I build the amplify backend in packages
npm create amplify@latest
? Where should we create your project? /packages/backend
npm add --save-dev @aws-amplify/backend@latest @aws-amplify/backend-cli@latest typescript
Then I build it on amplify, the system detected it as amplify gen2, and use the following amplify.yml build setting
version: 1
applications:
- 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:
- npx nx build shared_backend
artifacts:
baseDirectory: dist
files:
- '**/*'
cache:
paths:
- .npm/**/*
buildPath: dist/packages/shared_backend
appRoot: packages/shared_backend
This will cause error saying "CustomerError: Build path does not exist, please check the 'buildPath' value in BuildSpec" How can i fix it?
https://docs.aws.amazon.com/amplify/latest/userguide/monorepo-configuration.html
I also try to change the buildpath to '/' according to this documentation, then i will get error that it cannot find the backend.ts file.
How can i fix this problem and successfully build a monorepo with Nx on amplify just like the documentation describe?
https://docs.amplify.aws/react/deploy-and-host/fullstack-branching/monorepos/
Upvotes: 0
Views: 75
Reputation: 1
I figure this out myself. I change the amplify build setting to the following
version: 1
applications:
-
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: ['mkdir ./dist && touch ./dist/index.html']
artifacts:
baseDirectory: dist
files:
- '**/*'
cache:
paths:
- '.npm/**/*'
appRoot: packages/shared_backend
Upvotes: 0