未加星标

PWA Laravel

字体大小 | |
[开发(php) 所属分类 开发(php) | 发布者 店小二04 | 时间 2018 | 作者 红领巾 ] 0人收藏点击收藏

Got this basic working PWA laravel with serviceworker, manifest...

Tried it offline when web finish loaded then turned off webserver and it still on...

Create Project Laravel

laravel new Pwa

get all dependencies

npm install

add another

npm install --save-dev sw-precache-webpack-plugin

copy webpack.config.js

below let WebpackConfig = require('../src/builder/WebpackConfig');

let path = require('path'); let glob = require('glob'); let webpack = require('webpack'); let webpackPlugins = require('laravel-mix').plugins; let dotenv = require('dotenv'); let SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');

below code module.exports = new WebpackConfig().build();

module.exports.plugins.push( new SWPrecacheWebpackPlugin({ cacheId: 'pwa', filename: 'service-worker.js', staticFileGlobs: ['public//.{css,eot,svg,ttf,woff,woff2,js,html}'], minify: true, stripPrefix: 'public/', handleFetch: true, dynamicUrlToDependencies: { '/': ['resources/views/welcome.blade.php'], }, staticFileGlobsIgnorePatterns: [/.map$/, /mix-manifest.json$/, /manifest.json$/, /service-worker.js$/], runtimeCaching: [{ urlPattern: /^https://fonts.googleapis.com//, handler: 'cacheFirst' } ], //importScripts: ['./js/pushmessage.js'] }) );

Create in public -> manifest.json

{ "shortname": "PWA", "name": "PWA App", "backgroundcolor": "#2196F3", "orientation": "portrait", "icons": [{ "src": "images/icons/icon-72x72.png", "sizes": "72x72", "type": "image/png" }, { "src": "images/icons/icon-96x96.png", "sizes": "96x96", "type": "image/png" }, { "src": "images/icons/icon-128x128.png", "sizes": "128x128", "type": "image/png" }, { "src": "images/icons/icon-144x144.png", "sizes": "144x144", "type": "image/png" }, { "src": "images/icons/icon-152x152.png", "sizes": "152x152", "type": "image/png" }, { "src": "images/icons/icon-192x192.png", "sizes": "192x192", "type": "image/png" }, { "src": "images/icons/icon-384x384.png", "sizes": "384x384", "type": "image/png" }, { "src": "images/icons/icon-512x512.png", "sizes": "512x512", "type": "image/png" } ], "starturl": "/", "display": "standalone" }

in the view

<!-- Web Application Manifest --> <link rel="manifest" href="/manifest.json"> <!-- Chrome for Android theme color --> <meta name="theme-color" content="#000000"> <!-- Add to homescreen for Chrome on Android --> <meta name="mobile-web-app-capable" content="yes"> <meta name="application-name" content="PWA"> <link rel="icon" sizes="512x512" href="/images/icons/icon-512x512.png"> <!-- Add to homescreen for Safari on iOS --> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-title" content="PWA"> <link rel="apple-touch-icon" href="/images/icons/icon-512x512.png"> <!-- Tile for Win8 --> <meta name="msapplication-TileColor" content="#ffffff"> <meta name="msapplication-TileImage" content="/images/icons/icon-512x512.png"> <script type="text/javascript"> if ('serviceWorker' in navigator) { navigator.serviceWorker .register('./service-worker.js') .then(function() { console.log('Service Worker Registered'); }); } </script>

Followed the tutorial from here

https://www.youtube.com/watch?v=ts7jDVikaN4

Source from here

https://justmegareth.com/2017-07-15-progressive-web-app-in-laravel/

Other Repo worth checking out

https://github.com/silviolleite/laravel-pwa*

本文开发(php)相关术语:php代码审计工具 php开发工程师 移动开发者大会 移动互联网开发 web开发工程师 软件开发流程 软件开发工程师

分页:12
转载请注明
本文标题:PWA Laravel
本站链接:https://www.codesec.net/view/620861.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(php) | 评论(0) | 阅读(9)