I created an angular 6 app using angular-cli, added some modules and components to it, and also some pipes in a shared module.
I can successfully build my application using ng build
and successfully run it using ng serve
.
But when I try to build the exact same application using ng build --prod
I'm getting the following error:
The pipe 'myPipe' could not be found
I do declare and export the pipe in the SharedModule, and I import SharedModule from the module where I'm using the pipe. Is there something in addition I need to do for production mode? Note that the module where I'm using the pipe is lazy-loaded, so maybe that makes a difference.
As a side-note: When building in production mode I'm also getting many errors regarding to font-awesome ("Can't bind to 'icon' since it isn't a known property of 'fa-icon'", "'fa-icon' is not a known element"), which I don't get when building a non-production version. But I thought I'll address the pipe problem first.
It was a stupid mistake... I actually forgot to import my SharedModule in one of my other modules. The error message made me think the error is occuring in some different module.
The difference between production and non-production build is simple: The non-production build failed as well, but only at runtime - while the production build failed at build time.