Building from subfolder (from Amplify's perspective) is same as a Monorepo.
Below code would build from /frontend/*
:
version: 1 applications: - appRoot: frontend frontend: phases: preBuild: commands: - yarn install --frozen-lockfile build: commands: - yarn run build artifacts: baseDirectory: .next files: - '**/*' cache: paths: - .next/cache/**/* - node_modules/**/*
Environment variable AMPLIFY_MONOREPO_APP_ROOT
must also be added to the Environment Variables
If your project has a flattened structure (meaning, when the entrypoint is at the root of the repository), you need to point both the appRoot
and the baseDirectory
to .
.
version: 1 applications: - frontend: buildPath: '.' phases: preBuild: commands: - yarn install --frozen-lockfile build: commands: - yarn run build artifacts: baseDirectory: .next files: - '**/*' cache: paths: - .next/cache/**/* - node_modules/**/* appRoot: '.'