Skip to content

Commit 4a4702c

Browse files
committed
tweak setup for pwa-ness
1 parent 8a297b4 commit 4a4702c

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

build/webpack.client.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ if (process.env.NODE_ENV === 'production') {
5454
}),
5555
new SWPrecachePlugin({
5656
cacheId: 'vue-hn',
57-
filename: 'service-worker.js'
57+
filename: 'service-worker.js',
58+
dontCacheBustUrlsMatching: /./,
59+
staticFileGlobsIgnorePatterns: [/index\.html$/, /\.map$/]
5860
})
5961
)
6062
}

manifest.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "Vue Hackernews 2.0",
3+
"short_name": "Vue HN",
4+
"icons": [{
5+
"src": "/logo.png",
6+
"sizes": "48x48",
7+
"type": "image/png"
8+
}],
9+
"start_url": "/",
10+
"background_color": "#f2f3f5",
11+
"display": "standalone",
12+
"theme_color": "#f60"
13+
}

server.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const isProd = process.env.NODE_ENV === 'production'
44
const fs = require('fs')
55
const path = require('path')
66
const express = require('express')
7-
const favicon = require('serve-favicon')
87
const compression = require('compression')
98
const serialize = require('serialize-javascript')
109
const resolve = file => path.resolve(__dirname, file)
@@ -50,8 +49,10 @@ function parseIndex (template) {
5049
}
5150

5251
app.use(compression({ threshold: 0 }))
53-
app.use('/dist', express.static(resolve('./dist'), { maxAge: isProd ? 60 * 60 * 24 * 30 : 0 }))
54-
app.use(favicon(resolve('./src/assets/logo.png')))
52+
const cacheConfig = { maxAge: isProd ? 60 * 60 * 24 * 30 : 0 }
53+
app.use('/dist', express.static(resolve('./dist'), cacheConfig))
54+
app.use('/manifest.json', express.static(resolve('./manifest.json'), cacheConfig))
55+
app.use('/logo.png', express.static(resolve('./src/assets/logo.png'), cacheConfig))
5556

5657
app.get('*', (req, res) => {
5758
if (!renderer) {

src/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ a
3838
background-color #ff6600
3939
position fixed
4040
z-index 999
41+
height 55px
4142
top 0
4243
left 0
4344
right 0

src/index.template.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
<meta charset="utf-8">
55
<title>vue-hackernews-2.0</title>
66
<meta name="mobile-web-app-capable" content="yes">
7-
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
7+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
8+
<link rel="shortcut icon" sizes="48x48" href="/logo.png">
9+
<meta name="theme-color" content="#f60">
10+
<link rel="manifest" href="/manifest.json">
811
<link href='https://fonts.googleapis.com/css?family=Roboto:300,400,700' rel='stylesheet' type='text/css'>
912
</head>
1013
<body>

0 commit comments

Comments
 (0)