[Angular] Upgrade existing Angular app to Progressive Web App
If you alread have an existing Angular application and want to upgrade to progressive web app.
1. Install @angular/service-worker:
npm i --save @angular/service-worker
2. Create a file: src/ngsw-config.json
{
"index": "./index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html"
],
"versionedFiles": [
"/*.bundle.css",
"/*.bundle.js",
"/*.chunk.js"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**"
]
}
}
]
}
3. Create a src/manifest.json file:
{
"dir": "ltr",
"lang": "en",
"name": "Application Name",
"scope": "/",
"display": "fullscreen",
"start_url": "http://localhost:8000/",
"short_name": "Application name",
"theme_color": "transparent",
"description": "All about your app",
"orientation": "any",
"background_color": "transparent",
"related_applications": [],
"prefer_related_applications": false,
"icons": [
{
"src": "/favicon.ico",
"sizes": "16x16 32x32"
},
{
"src": "/assets/android-icon-36x36.png",
"sizes": "36x36",
"type": "image/png",
"density": "0.75"
},
{
"src": "/assets/android-icon-48x48.png",
"sizes": "48x48",
"type": "image.png",
"density": "1.0"
},
{
"src": "/assets/android-icon-72x72.png",
"sizes": "72x72",
"type": "image/png",
"density": "1.5"
},
{
"src": "/assets/android-icon-96x96.png",
"sizes": "96x96",
"type": "image/png",
"density": "2.0"
},
{
"src": "/assets/android-icon-144x144.png",
"sizes": "144x144",
"type": "image/png",
"density": "3.0"
},
{
"src": "/assets/android-icon-192x192.png",
"sizes": "192x192",
"type": "image/png",
"density": "4.0"
}
]
}
4. Update .angular-cli.json file:
{
"apps": [
{
"root": "src",
...
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
},
"serviceWorker": true
}
}
5. Import ServiceWorkerModule in app.module.ts file:
import {ServiceWorkerModule} from '@angular/service-worker';
@NgModule({
declarations: [
AppComponent
],
imports: [
...
ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production})
],
...
bootstrap: [AppComponent]
})
export class AppModule {
}
'ngsw-worker.js' will be created in dist folder after we build the application in production mode.
6. Run:
ng build --prod
7. cd to dist folder, run in local server.
[Angular] Upgrade existing Angular app to Progressive Web App的更多相关文章
- 说说 PWA 和微信小程序--Progressive Web App
作者:云图图链接:https://zhuanlan.zhihu.com/p/22578965来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 利益相关:微信小用户,谷歌小 ...
- [io PWA] keynote: Launching a Progressive Web App on Google.com
Mainly about Material design (effects / colors / flashy stuff) Components (web components / polymer) ...
- (转)PWA(Progressive Web App)渐进式Web应用程序
PWA 编辑 讨论 PWA(Progressive Web App)是一种理念,使用多种技术来增强web app的功能,可以让网站的体验变得更好,能够模拟一些原生功能,比如通知推送.在移动端利用标准化 ...
- Progressive web app理念及发展前景
前一段时间微信推出微信小程序进行公测,着实火了一把,博得了大众的眼球,不明真相的吃瓜观众们纷纷围观,所谓的“微信小程序”,通俗的讲就是一种不需要下载安装即可使用的应用程序,脱离于app商店依托于浏览器 ...
- PWA(Progressive Web App)入门系列:(一)PWA简单介绍
前言 PWA做为一门Google推出的WEB端的新技术,长处不言而喻.但眼下对于相关方面的知识不是非常丰富.这里我推出一下这方面的新手教程系列.提供PWA方面学习. 什么是PWA PWA全称Progr ...
- Progressive Web App是一个利用现代浏览器的能力来达到类似APP的用户体验的技术——不就是chrome OS吗?
什么是Progressive Web App? Progressive Web App是一个利用现代浏览器的能力来达到类似APP的用户体验的技术,由Google实现,让浏览器打开的网址像APP一样运行 ...
- 原生APP与移动Web App的比较
中国手机网民已超4.5亿,智能机用户超过3.8亿,中国移动互联网市场产值已超过712.5亿元,手机营销是未来必然趋势,而App恰恰是这个趋势下的一个强有力的营销工具: App已有两个主要的方向:原生A ...
- Progressive Web App
下一代 Web 应用? 近年来,Web 应用在整个软件与互联网行业承载的责任越来越重,软件复杂度和维护成本越来越高,Web 技术,尤其是 Web 客户端技术,迎来了爆发式的发展. 包括但不限于基于 N ...
- Native App开发 与Web App开发(原生与web开发优缺点)
Native App开发 Native App开发即我们所称的传统APP开发模式(原生APP开发模式),该开发针对IOS.Android等不同的手机操作系统要采用不同的语言和框架进行开发,该模式通常是 ...
随机推荐
- spring的bean管理(注解和配置文件混合使用)
1.建三个类,在一个类中引用其他两个类 import javax.annotation.Resource; import org.springframework.beans.factory.annot ...
- web 单一平台登录逻辑
单点登录逻辑token=cookie('login_token');serverToken=get(token);if(serverToken!='注销'){ set('userid_已登录token ...
- etcd创建集群并增加节点
下载安装 从这下载https://github.com/coreos/etcd/releases/download/v3.3.2/etcd-v3.3.2-linux-amd64.tar.gz tar ...
- 解决 dotnet core 1.x 命令行(cli) 下运行路径错误
环境: Windows 10,Visual Studio 2017 centos 7,nginx,supervisor,dotnet core 1.1 问题: 在 Linux 配置 superviso ...
- Hdu-2892 area 计算几何 圆与凸多边形面积交
题面 题意:有一个凸多边形岛屿,然后告诉你从高空(x,y,h)投下炸弹,爆炸半径r,飞机水平速度和重力加速度,问岛屿被炸了多少 题解:算出来岛屿落地位置,再利用圆与凸多边形面积交 #include&l ...
- 了解php数据转json格式与前端交互基础
php数据转json格式与前端交互 ArryJson1.php <?php $test=array(); $word=array("我12","要43", ...
- POJ 2513 trie树+并查集判断无向图的欧拉路
生无可恋 查RE查了一个多小时.. 原因是我N define的是250500 应该是500500!!!!!!!!! 身败名裂,已无颜面对众人.. 吐槽完了 我们来说思路... 思路: 判有向图能否形成 ...
- Super超级ERP系统---(5)采购管理--采购入库
采购商品完成后,下一步要进行入库操作.为了做到精细化管理,入库操作主要分以下几个步骤,采购到货确认,采购入库,入库完成.接下来我们看看这些步骤是怎样实现的. 1.到货确认 采购商品到达仓库后,仓库收货 ...
- Junit使用第二弹
实例总结 1. 参数化测试 有时一个测试方法,不同的参数值会产生不同的结果,那么我们为了测试全面,会把多个参数值都写出来并一一断言测试,这样有时难免费时费力,这是我们便可以采用参数化测试来解决这个问题 ...
- ubuntu 搭建Mercurial 服务(nginx)
ubuntu 搭建Mercurial 服务(nginx) 环境:ubuntu 12.05 Mercurial 步骤: (1)安装nginx 和 Mercurial: sudo apt-get ins ...