FROM node:10-alpine
WORKDIR /work
RUN yarn global add @angular/cli@7.0.3
RUN ng new --defaults --skipInstall=true angular7
WORKDIR /work/angular7
RUN yarn
CMD ng serve --host `hostname`
$ ng new angular7
? Would you like to add Angular routing? No
? Which stylesheet format would you like to use? SCSS [ http://sass-lang.com ]
CREATE angular7/angular.json (3877 bytes)
CREATE angular7/package.json (1315 bytes)
...
次に、デプロイ用のファイル一式を「angular7/public」ディレクトリへ生成する。
$ cd angular7
$ ng build --prod --output-path=public
? Are you ready to proceed?
-> Yes
? Which Firebase CLI features do you want to setup for this folder? Press Space to select features, then Enter to confirm your choices.
-> Hosting: Configure and deploy Firebase Hosting sites
? Select a default Firebase project for this directory:
-> angular7-xxxxx (angular7)
? What do you want to use as your public directory?
-> public
? Configure as a single-page app (rewrite all urls to /index.html)?
-> No
? File public/index.html already exists. Overwrite?
-> No
そしてデプロイを実行する。
$ firebase deploy
=== Deploying to 'angular7-xxxxx'...
i deploying hosting
i hosting[angular7-xxxxx]: beginning deploy...
i hosting[angular7-xxxxx]: found 8 files in public
+ hosting[angular7-xxxxx]: file upload complete
i hosting[angular7-xxxxx]: finalizing version...
+ hosting[angular7-xxxxx]: version finalized
i hosting[angular7-xxxxx]: releasing new version...
+ hosting[angular7-xxxxx]: release complete
+ Deploy complete!
Project Console: https://console.firebase.google.com/project/angular7-xxxxx/overview
Hosting URL: https://angular7-xxxxx.firebaseapp.com
Angular CLI 7.X で ng new を実行すると、routingの使用やスタイルシートのフォーマットについて聞かれる。
$ ng new virtualscrolling
? Would you like to add Angular routing? No
? Which stylesheet format would you like to use? SCSS [ http://sass-lang.com ]
CREATE virtualscrolling/angular.json (3949 bytes)
CREATE virtualscrolling/package.json (1323 bytes)
CREATE virtualscrolling/README.md (1033 bytes)
...
プロジェクトができたところで、Angularのバージョンを確認してみる。
$ cd virtualscrolling
$ ng version
...
Angular CLI: 7.0.2
Node: 8.12.0
OS: win32 x64
Angular: 7.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
...
$ ng new helloworld
$ cd helloworld
$ ng serve --open
デフォルトのブラウザ(例えばChrome)に「Welcome to helloworld!」と(一応「helloworld」と)表示される^^;
ちょっと手抜きすぎるので、本当にAngular6.1になっているのか確認してみる。app.component.tsでtitleにバージョンを埋め込んでみる。
import {Component, VERSION} from '@angular/core';
~略~
export class AppComponent {
title = `helloworld (${VERSION.full})`;
}
「Welcome to helloworld (6.1.10)!」と表示され、Angular6.1.10であることが分かった。ng -vでも分るようだ。