below instructions are from: https://github.com/csr632/angular-aot-demo-with-ngc-webpack
A minified project to learn Angular5 aot with ngc
(Angular compiler cli) and webpack. Also demonstrate how to import 3rd lib such as jQuery.
similar to https://github.com/csr632/angular-aot-demo-with-ngc-rollup, but this project use webpack instead of rollup, so lazy loading Angular module is possible.
This project use ngc
to generate compiled Angular code and write it to disk, and then bundle the js code from disk. This make you be able to observe the code generate by angular compiler, and even edit it to see the difference! I think it is really helpful to understand & play with the "low-level machine code" of Angular.
If you just want a minimum configuration to start building your own components to play with the ngc output, switch to mini branch.
If you don't care how is the bundle generated and served, just use
npm run dev
and everything will be watched and updated properly.
npm run compile
: usengc
(angular compiler cli) to compile the "angular syntax" into js code(the "low-level machine code"). You can observe the output incompile_output/
.npm run compile:watch
: same asnpm run compile
, except this command will also listen for source files' change and emit latest compiled.js
code.npm run webpack
: pack the whole application(including application code, angular framework, 3rd lib) into several bundles, based on thewebpack.config.js
. Note that the output ofngc
is (part of) the input of webpack, so you must have finishednpm run compile[:watch]
before running this command.npm run serve
: first, bundle the whole application(similar tonpm run webpack
but will emit files into memory instead of disk and listen for source files' change). Then, serve the emitted files from memory. You must have finishednpm run compile[:watch]
before running this command (whilenpm run webpack
is not required).npm run clean
: cleandist/*
,compile_output/*
.npm run aot
:npm run clean && npm run compile && npm run webpack
.npm run dev
: bundle and serve the application. This command will listen for source files' change as well as ngc outputs' change. So you can edit these two things and the served bundle will update immediately.
- skipMetadataEmit in
tsconfig.json
determine whether or not Angular Compiler emit.metadata.json
files. - skipTemplateCodegen in
tsconfig.json
determine whether or not Angular Compiler emit.ngfactory.js
and.ngstyle.js
files. declaration
intsconfig.json
determine whether or not TypeScript Compiler emit.d.ts
definition files.sourceMap
intsconfig.json
determine whether or not TypeScript Compiler emit.js.map
sourcemap files.