CLI Commands - aakash14goplani/FullStack GitHub Wiki

  1. ng g c <component_name> or ng generate component <component_name>: Generates a component in new folder with .ts, .html, .css and .spec file
    ng g c <component_name> --skipTests=true: generates a component in a new folder without spec files

  2. ng serve: Builds and serves your app, rebuilding on file changes

  3. npm install --save-dev bootstrap@3: install package in DEV only

  4. ng new <project_name>: creates new angular project

  5. Upgrade to new angular version: ng update @angular/cli @angular/core

  6. ng build --prod: builds a dist folder that contains code which will be deployed to PROD.

  7. ng add <package_name>: adds new package

  8. Create sub-projects:

    ng generate application <sub_project_name>
    ng serve --project=<sub_project_name>
    
    • It adds new projects folder that has this sub-project. It is bit light as it shares all configuration (like node_modules) with main project. Only angular.json files gets updated.
    • If you already know that your project is going to have many sub projects, you can configure that in start:
      ng new --create-application=false
      ng generate application <sub_project_name>
      ng serve --project=<sub_project_name>
      
    • --create-application=false creates a light project i.e. installs all dependencies but omits app folder. You then create other sub-projects within projects` folder by running pending 2 commands.

Reference