Skip to content

sonicoder86/angular2-aot-cli-webpack-plugin

Repository files navigation

Angular AOT (Ahead Of Time) compilation with the Angular CLI Webpack plugin

Dependency Status devDependency Status

This repository shows how to use the Angular CLI Webpack plugin (@ngtools/webpack) to achieve AOT offline compilation.

It can also work with the new @utlimate/aot-loader package and has very similar configuration. See example in separate branch.

If you prefer the command line tool (ngc) provided by Angular, it can be found in a separate repository.

The application consists of a module (src/app/modules/main.module.ts) and a basic component (src/app/components/hello-world.component.ts) with template (src/app/components/hello-world.template.pug) and component specific style (src/app/components/hello-world.style.sass).

When the application starts (npm start) it generates the compiled files in memory and replaces the bootstrap logic to use the generated NgFactory files.

The application is bundled with Webpack from the main file and is available on http://localhost:9000.

Advantages

  • Custom file types available for templates and styles through Webpack loaders (sass, pug,...)
  • No separate process for compilation
  • Watch mode for AOT compiled files
  • No need to maintain AOT version of bootstrap file
  • No output to disk for separate *.ngfactory.ts files during compilation

Disadvantages

  • Need to wait for new versions after Angular release to Angular CLI repository catch up
  • Not good for AOT compatible package publishing, because it doesn't output separate compiled files

Known issues

Further reading

Starters with AOT compilation available

About

Angular AOT (Ahead Of Time) compilation with Webpack plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published