How to build web in Ionic 5

I am trying to build web app using Ionic 5
I have tried:

ionic cordova build browser --prod --release

and

ionic serve --prod

both failed and have error like:

1. If 'ion-header' is an Angular component, then verify that it is part of this module.
2. If 'ion-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
1. If 'ion-icon' is an Angular component, then verify that it is part of this module.
2. If 'ion-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the'@NgModule.schemas' of this component to suppress this message.

It seems that when building production, it doesnot regconize ionic component.

I am fine when I use following command:

ionic serve

so how to deal with it?
Thanks

I have tested ionic build and ionic build --prod
ionic build works but ionic build --prod doesnt, it shows same error

Have you try to host www folder as web. As far as i know that works fine for web.

Try looking through these forum search results.