To create a production build for a remote server I usually run following ng command:
This Angular post is compatible with Angular 4 upto latest versions, Angular 7, Angular 8, Angular 9, Angular 10, Angular 11 & Angular 12
$ ng build --prod
But at the client end, there was some stage error popping up in the console and the application was not loading. Surprisingly it was working fine on my end and on my mobile network as well.
The error was something like this:
Error Uncaught SyntaxError: Unexpected token ‘,’
and sometimes this:
Error Uncaught SyntaxError: Unexpected token ‘<‘
I tried to create the production again and again but the same thing was happening…
Then After reading some forums, I got to know, it is something related to Hashing added to the map file during production build.
So I ran this which resolved this issue:
$ ng build --aot --prod --output-hashing none
After that, it created the bundle without any Hashing using Ahead Of Time compilation which resolved this issue at all places.
Hope this can help somebody 🙂