简体   繁体   English

Angular4设置指南

[英]Angular4 setup guide

It seems that angular-cli is very much in favor at the moment but I would like to get a better understanding of setting up a new Angular (V4) project. 目前看来,angular-cli非常受欢迎,但我希望对建立新的Angular(V4)项目有更好的了解。

During this setup I would also like to fully understand the impact of integrating WebPack. 在此设置过程中,我还想充分了解集成WebPack的影响。 I'd prefer not to use the "ng eject" option as I would like total control over the configuration right from the start in order that I can experiment. 我不想使用“ ng弹出”选项,因为我希望从一开始就完全控制配置,以便可以进行试验。

I am really struggling to find any up-to-date tutorials using the latest version of Angular and NOT using the angular-cli. 我真的很难找到使用最新版本的Angular而不是使用angular-cli的任何最新教程。

Can anyone point me in the right directions for tutorials or perhaps a decent seed with the absolute minimum skeleton framework? 谁能为我指出正确的指导方向,或者为我提供一个绝对最低限度的骨架的种子?

Thanks 谢谢

You can refer this link for the understanding of webpack. 您可以参考此链接以了解webpack。 After reading this you will be able to experiment. 阅读此书后,您将可以进行实验。

Angular webpack Angular Webpack

For creating angular application other than angular cli you can try this using VS. 要创建除角度cli以外的角度应用,您可以使用VS进行尝试。 Refer this Building Angular app with Visual studio . 通过Visual Studio引用此Building Angular应用程序

when you create a new project with angular cli, it is sufficient and minimum to start experimenting. 当您创建带有角度cli的新项目时,开始实验就足够了,而且最少。 (It is my opinion.) (这是我的意见。)

In general it's a good approach to know what's happening in that CLI blackbox but I must say the learning curve is steep. 通常,这是了解CLI黑盒中正在发生什么的好方法,但是我必须说学习曲线很陡峭。 If you have ever used "ng eject" and had a look into the webpack config that is generated, you know what I'm talking about. 如果您曾经使用过“ ng弹出”并查看了生成的webpack配置,那么您知道我在说什么。 I would suggest to start learning webpack, setup a simple project and extend it step by step. 我建议开始学习webpack,设置一个简单的项目,并逐步扩展它。

In most cases you need 2 configuration files, one for local development and one for the distribution build. 在大多数情况下,您需要2个配置文件,一个用于本地开发,一个用于发行版本。 I prefer to use a "common" config and use the webpack-merge plugin to extend it for the dev and dist build. 我更喜欢使用“公共”配置,并使用webpack-merge插件将其扩展为开发和发行版本。

Then add plugins and loaders to support typescript, less and asset files like pictures and fonts. 然后添加插件和加载程序以支持打字稿,更少的图片文件和字体等资产文件。 Also adding Angular in a simple webpack project works without any problems but to get the equal feature support as ng-CLI including AOT, lazy loading and other specialized optimizations you need to use the ngtools webpack plugin: https://www.npmjs.com/package/@ngtools/webpack 同样在一个简单的webpack项目中添加Angular也没有任何问题,但是要获得与ng-CLI相同的功能支持,包括AOT,延迟加载和其他专门的优化,您需要使用ngtools webpack插件: https ://www.npmjs.com / package / @ ngtools / webpack

In the process of learning you will definitely figure out how helpful ng-CLI is and how much complexity it keeps away from the user. 在学习过程中,您一定会弄清楚ng-CLI的实用性以及它远离用户的复杂程度。 The Advantage of having an custom setup is clearly the full control and extendability of Webpack. 具有自定义设置的优势显然是Webpack的完全控制和可扩展性。 Especially if you depend on custom webpack plugins there is no way around having an own webpack configuration. 特别是如果您依赖于自定义的webpack插件,就无法拥有自己的webpack配置。

I once started an approach to have an Angular project without ng-CLI, it's out-of-date but maybe you can get an impression of how to do it: https://github.com/TekTimmy/angular2-seed 我曾经开始一种没有ng-CLI的Angular项目的方法,它已经过时了,但是也许您可以对如何做有一个印象: https : //github.com/TekTimmy/angular2-seed

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM