Angular-cli
對於Angular2 的使用以及一開始的環境設置,Angular-cli給了不小的幫助
這邊來做一下紀錄大概利用了angular-cli的過程和方法
更詳細的部份可以詳見在github上面angular-cli的專案
# 安裝angular-cli
npm install angula-cli
# 一開始的專案創建
ng new <project-name>這樣就是專案部份的建立,建立的同時也會把git repositary init起來
在進行專案,首要部份就是module, component, service各項部件的建立
在更詳細的部份其實可以進去node_modules/ng裡面的blueprint去看他的sourcecode
| 架構 | 指令 | 
|---|---|
| Component | ng g component my-new-component | 
| Directive | ng g directive my-new-directive | 
| Pipe | ng g pipe my-new-pipe | 
| Service | ng g service my-new-service | 
| Class | ng g class my-new-class | 
| Interface | ng g interface my-new-interface | 
| Enum | ng g enum my-new-enum | 
| Module | ng g module my-module | 
在使用的時候其實還有額外的參數指令可以下
例如說當我不需要使用spec在創建component的選項時,可以加入以下命令
ng g component --spec=false <name>或者說對於很多其他的選項可以在node_modules/angular-cli/blueprint的index.js裡面都可以查到定義
一些其他的功能
- 提供Hot Reload即時線上看
ng serve
# listen on localhost:4200- 輸出網站整體
ng build
# 可以將網站進行最小化,使用prod的模式
ng build --target=production --environment=prod
ng build --prod --env=prod
ng build --prod
留言
張貼留言