Angular允许我们构建可以部署到移动,Web和桌面的高性能Web应用程序。Firebase Hosting是一个流行的服务,易于使用CLI工具。在本文中,我们将使用Travis CI来自动化此部署。
新增角度应用
使用ANGLE CLI]创建新的角度项目以建立公用基:
1# Install the Angular CLI
2$ npm i @angular/cli -g
3
4# Create a new Angular project with the name of your choosing && change directory
5$ ng new AngularFirebaseCI
6
7> N
8> SCSS
9
10$ cd AngularFirebaseCI
11
12# Open this up in VS Code and Serve
13$ code . && ng serve
现在,我们可以创建一个基本的角度项目。转到app.Component.html
并创建以下模板:
1<section>
2 <article>
3 <h1>Angular, Travis CI & Firebase Hosting</h1>
4 <p>🔥🔥🔥</p>
5 </article>
6</section>
我们还可以在app.Component.scss
中添加一些CSS样式,使其更具魔力:
1section {
2 display: flex;
3 justify-content: center;
4 align-items: center;
5 height: 100vh;
6 background: #8a2387;
7 background: -webkit-linear-gradient(to right, #f27121, #e94057, #8a2387);
8 background: linear-gradient(
9 to right,
10 #f27121,
11 #e94057,
12 #8a2387
13 );
14}
15
16article {
17 text-align: center;
18 color: white;
19 padding: 40px;
20 box-shadow: 1px 1px 200px rgba(0, 0, 0, 0.8);
21}
最后,在全局styles.scss
中,我们默认html
和body
样式:
1html,
2body {
3 padding: 0px;
4 margin: 0px;
5}

6i hosting: uploading new files [12/14] (85%)
7✔ hosting[app-5c310]: file upload complete
8i hosting[app-5c310]: finalizing version...
9✔ hosting[app-5c310]: version finalized
10i hosting[app-5c310]: releasing new version...
11✔ hosting[app-5c310]: release complete
12✔ Deploy complete!
总结
在本文中,我们介绍了如何使用Angular创建应用程序并将其部署到Firebase Hosting。
然后,我们研究了如何使用Travis CI自动执行此过程。只要`master‘分支更新,这个构建过程就会运行并发布到Firebase主机上。