Vinay
Vinay

Reputation: 962

Error while doing ng Prod build for angular 2 project

I have a angular2 project, whenever I try to serve the project or build it, it works fine (creates a dist folder for the ng build command), but whenever I try to build the same project with prod tag turned on (ng build --prod), the compilation fails with a lot of similar error(Property 'XXX' does not exist) like below,

ERROR in ng:///C:/Users/username/Desktop/Latest/ang-project/ui/src/app/components/full-
header/full-header.component.html (12,22): Property 'Test' does not exist on typ
e 'FullHeaderComponent'.

I seem to remember that the prod flag makes use of aot compilation internally - is it so?

If it does use aot, should I be enabling the AOT in my project(And if yes how should I be doing it?)

Upvotes: 2

Views: 648

Answers (1)

eko
eko

Reputation: 40647

--prod indeed uses aot compilation.

  Flag                    --dev       --prod
--aot                       false       true
--environment               dev         prod
--output-hashing            media       all
--sourcemaps                true        false
--extract-css               false       true

Source: https://github.com/angular/angular-cli/wiki/build#--dev-vs---prod-builds

Upvotes: 4

Related Questions