@angular/cli is a package that allows you to create/run/test/build an Angular application.
You can install it globally
npm i -g @angular/cli
If you run the cli commands in a project that also has the cli installed it will use the project cli version instead.
Why @angular/cli and not my bootstrap?
Well, there are so many things you have to configure to get to the same level… webpack (and all those loaders), webpack-dev-server, jasmine, karma, protractor, tslint, typescript…
If you don’t want everything it creates there is actually a
--minimal parameter on
All commands have a
--help that provides a lot of useful information. Also the documentation can be found here.
ng new is a command that generates an Angular application for you, if you want to use SCSS you have to run with the parameter
If you already generated and want to change to SCSS you can edit
defaults.styleExt in the file
.angular-cli.json, or run the command
ng set defaults.styleExt scss. But you will have to rename files manually.
ng generate can be used to generate classes, components, directives, enums, pipes, services… It automatically create the files for you.
ng g c login
installing component create src\app\login\login.component.css create src\app\login\login.component.html create src\app\login\login.component.spec.ts create src\app\login\login.component.ts update src\app\app.module.ts
ng serve builds the app and starts a server, behind the scenes it starts a
webpack-dev-server on port 4200.
ng lint will run tslint on your application.
ng test will run your applications tests (
ng e2e will run your application end-to-end tests (not the same as
ng build will build your application, you can generate production assets by running
ng build --prod.
ng get / ng set
ng get will get a value from the configuration (
ng set will update a value on the configuration.
ng doc will open Angular documentation with the specified keyword.
ng eject will extract files and configuration from @angular/cli making it no longer required. It then changes package.json to use
karma and other libraries directly. It also extracts
webpack.config.js allowing you to change how the app is built.
ng xi18n extracts i18n messages from the templates.