Angular 2 with CLI - build for production

后端 未结 9 1862
夕颜
夕颜 2021-02-01 16:18

I have freshly installed angular-cli 1.0.0.beta.17 (latest one), start new project, able to serve project on port 4200 with no problems - just standard \"app works!\" message.

9条回答
  •  孤街浪徒
    2021-02-01 17:00

    You must update latest version angular-cli, typescript. If you use command:

    ng build --prod --aot=false
    

    Your project compile JIT compilation and must be work if you use angular-cli.

    if you want build with command

    ng build --prod --aot=true
    

    then it be AOT compilation and you must update main.ts file into:

    import { enableProdMode } from '@angular/core';
    import { platformBrowser }    from '@angular/platform-browser';
    
    import { AppModule } from './app/app.module';
    import { environment } from './environments/environment';
    
    if (environment.production) {
      enableProdMode();
    }
    
    platformBrowser().bootstrapModuleFactory(AppModule);
    

提交回复
热议问题