Error building NextJS with @sentry/nextjs on AWS Amplify

I’m just trying to integrate sentry with NextjS v12 using @sentry/nextjs and sentry wizard, everything is fine on localhost, but when I build the app on AWS Amplify, the build is error when starting SSR build with multiple error regarding Module not found: Can’t resolve ‘webpack’.

What is wrong with the build? Is there any solution for this? I have tried several options like adding target: ‘experimental-serverless-trace’ on next.config.js but no luck.

Appreciate your help!