angular
angular-cli

[Angular CLI] 入門 (cli@1.5.0-rc.6, core@5.0.0-rc.8)

More than 1 year has passed since last update.

本格的にAngular CLIに取り組む

インストール

$ sudo npm i -g @angular/cli
$ ng --version
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.4.9
node: 8.6.0
os: linux x64

プロジェクト作成からのビルド

$ cd /path/to/project
$ ng new webroot
$ cd webroot
$ npm run build

> webroot@0.0.0 build /path/to/project/webroot
> ng build

Date: 2017-10-28T07:36:24.780Z
Hash: a0174389afa0ca3d52cd
Time: 7262ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 7.85 kB {vendor} [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 199 kB {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.3 kB {inline} [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.28 MB [initial] [rendered]

package.json のアップデート

@angular/core@5.0.0-rc.8, @angular/cli@1.5.0-rc.6にアップデート
(2017-10-28時点)

package.json
{
  "name": "webroot",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.0.0-rc.8",
    "@angular/common": "^5.0.0-rc.8",
    "@angular/compiler": "^5.0.0-rc.8",
    "@angular/core": "^5.0.0-rc.8",
    "@angular/forms": "^5.0.0-rc.8",
    "@angular/http": "^5.0.0-rc.8",
    "@angular/platform-browser": "^5.0.0-rc.8",
    "@angular/platform-browser-dynamic": "^5.0.0-rc.8",
    "@angular/router": "^5.0.0-rc.8",
    "core-js": "^2.5.1",
    "rxjs": "^5.5.2",
    "zone.js": "^0.8.18"
  },
  "devDependencies": {
    "@angular/cli": "^1.5.0-rc.6",
    "@angular/compiler-cli": "^5.0.0-rc.8",
    "@angular/language-service": "^5.0.0-rc.8",
    "@types/jasmine": "^2.6.2",
    "@types/jasminewd2": "^2.0.2",
    "@types/node": "^6.0.60",
    "codelyzer": "^3.2.0",
    "jasmine-core": "^2.8.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^1.7.0",
    "karma-chrome-launcher": "^2.2.0",
    "karma-cli": "^1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "^1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.2.0",
    "ts-node": "^3.3.0",
    "tslint": "^5.8.0",
    "typescript": "^2.5.3"
  }
}

Production Build

$ npm run build -- --prod

> webroot@0.0.0 build /path/to/project/webroot
> ng build "--prod"

Date: 2017-10-28T07:53:19.592Z
Hash: d6a01f1846c465f58014
Time: 18898ms
chunk {0} polyfills.656f60bebda0fce711d9.bundle.js (polyfills) 60.9 kB {3} [initial] [rendered]
chunk {1} main.15f90abbc05b7bd46b2e.bundle.js (main) 52.5 kB {3} [initial] [rendered]
chunk {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 0 bytes {3} [initial] [rendered]
chunk {3} inline.b6bfc8741991589e13b9.bundle.js (inline) 1.45 kB [entry] [rendered]

to be continued...