angular-cli and multiple configuration files

2019-05-22 15:31发布

问题:

I have started using angular-cli for a new Angular 2 project. The starter project generates lots of configuration files, I'm not 100% sure about the purpose of all the files, couldn't find comprehensive documentation too.

What are the following files for?

MyApp/
..tslint.json
..tsconfig.json
..protractor.conf.js
..package.json
..karma.conf.js
..angular-cli.json
..src/
  ..tsconfig.app.json
  ..tsconfig.spec.json
..e2e/
  ..tsconfig.e2e.json

回答1:

Those are configuration files for different parts of your angular application:

  • tslint.json: settings for the static linting of your typescript code. (e.g. ensure single/double quotes)
  • tsconfig.json: settings for typescript compiler e.g. compiling to es5 or es6 (default settings, that others ineherit from):
    • tsconfig.app.json: settings for app
    • tsconfig.spec.json: settings for unit tests
    • tsconfig.e2e.json: settings for end to end tests (web tests)
  • protractor.conf.js: settings for e2e testing framework
  • karma.conf.js: configuration for the unit testing framework
  • package.json: settings for your npm package (dependencies, run scripts, repositroy, ...)
  • angular-cli.json: settings for your angular cli (e.g. to enable service worker support)