What does --minimal do in angular-cli `ng new`?

浪子不回头ぞ 提交于 2019-12-20 09:49:28

问题


The Angular CLI has an option called --minimal. What does it do and where is it documented? The command ng help new says very little about it

--minimal (Boolean) (Default: false) Should create a minimal app.
  aliases: --minimal

回答1:


Current as of July 31, 2017 A regular angular app generates 5 directories, 26 files. A --minimal generates 4 directories, 13 files. The difference? --minimal excludes generation of multiple files by enabling some other options.

  • You can see this in the code here
    • --skip-tests: stops the generation of testing (viz. e2e, karma.conf.js, protractor.conf.js, and *.spec. files) including tsconfig.spec.json, app.component.spec.ts
    • --inline-style: stops the generation of external css stubs instead keeping an empty string in the .ts file.
    • --inline-template: stops the generation of external html instead keeping it in the template variable in the .ts file.
  • Stops the generation of the following files, code here
    • README.md
    • tsconfig and tslint
    • favicon.ico

Here are the example's generated without --minimal

my-app/
├── e2e
│   ├── app.e2e-spec.ts
│   ├── app.po.ts
│   └── tsconfig.e2e.json
├── karma.conf.js
├── package.json
├── package-lock.json
├── protractor.conf.js
├── README.md
├── src
│   ├── app
│   │   ├── app.component.css
│   │   ├── app.component.html
│   │   ├── app.component.spec.ts
│   │   ├── app.component.ts
│   │   └── app.module.ts
│   ├── assets
│   ├── environments
│   │   ├── environment.prod.ts
│   │   └── environment.ts
│   ├── favicon.ico
│   ├── index.html
│   ├── main.ts
│   ├── polyfills.ts
│   ├── styles.css
│   ├── test.ts
│   ├── tsconfig.app.json
│   ├── tsconfig.spec.json
│   └── typings.d.ts
├── tsconfig.json
└── tslint.json

--minimal does the following

├── package.json
├── package-lock.json
├── src
│   ├── app
│   │   ├── app.component.ts
│   │   └── app.module.ts
│   ├── assets
│   ├── environments
│   │   ├── environment.prod.ts
│   │   └── environment.ts
│   ├── index.html
│   ├── main.ts
│   ├── polyfills.ts
│   ├── styles.css
│   ├── tsconfig.app.json
│   └── typings.d.ts
└── tsconfig.json



回答2:


Currently as of 2018 Dec and with Angular cli 7.0.7, minimal option has been added back. It means Create a barebones project without any testing frameworks.

You can check angular cli version 7 document for the list of options.

Below is the list of options return by ng new --help command.

ng new --help 
arguments:
  name
    The name of the workspace.

options:
  --collection (-c)
    Schematics collection to use.
  --commit 
    Initial repository commit information.
  --create-application 
    Flag to toggle creation of an application in the new workspace.
  --defaults 
    When true, disables interactive input prompts for options with a default.
  --directory 
    The directory name to create the workspace in.
  --dry-run (-d)
    When true, run through and report activity without writing out results.
  --experimental-ivy 
    EXPERIMENTAL: Specifies whether to create a new application which uses the Ivy rendering engine.
  --force (-f)
    When true, force overwriting of existing files.
  --help 
    Shows a help message for this command in the console.
  --inline-style (-s)
    Specifies if the style will be in the ts file.
  --inline-template (-t)
    Specifies if the template will be in the ts file.
  --interactive 
    When false, disables interactive input prompts.
  --minimal 
    Create a barebones project without any testing frameworks
  --new-project-root 
    The path where new projects will be created.
  --prefix (-p)
    The prefix to apply to generated selectors.
  --routing 
    Generates a routing module.
  --skip-git (-g)
    Skip initializing a git repository.
  --skip-install 
    Skip installing dependency packages.
  --skip-tests (-S)
    Skip creating spec files.
  --style 
    The file extension to be used for style files.
  --verbose (-v)
    Adds more details to output logging.
  --view-encapsulation 
    Specifies the view encapsulation strategy.

As of Angular cli 6.0.8, minimal option seems to have been removed. You may have to run --skip-tests, --inline-style and --inline-template like the other answer suggests to get the minimal project.

According to angular cli wiki page, these are the options available
dry-run
force
verbose collection
inline-style
inline-template
view-encapsulation
routing
prefix
style
skip-tests
skip-package-json

If you run this command: ng new --help , you can see what options are available with Angular cli 6.0.8

usage: ng new <name> [options]  
options:  
  --collection (-c)  
    Schematics collection to use.  

--directory   
    The directory name to create the workspace in.  

--dryRun (-d)  
    Run through without making any changes.  

--force (-f)  
    Forces overwriting of files.  

--inline-style (-s)  
    Specifies if the style will be in the ts file.  

--inline-template (-t)  
    Specifies if the template will be in the ts file.  

--new-project-root   
    The path where new projects will be created.  

--prefix (-p)  
    The prefix to apply to generated selectors.  

--routing   
    Generates a routing module.  

--skip-git (-g)  
    Skip initializing a git repository.  

--skip-install   
    Skip installing dependency packages.  

--skip-tests (-S)  
    Skip creating spec files.  

--style   
    The file extension to be used for style files.  

--verbose (-v)  
    Adds more details to output logging.  

--view-encapsulation   
    Specifies the view encapsulation strategy. 


来源:https://stackoverflow.com/questions/45429245/what-does-minimal-do-in-angular-cli-ng-new

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!