Commit 4a4702c8 authored by Evan You's avatar Evan You

tweak setup for pwa-ness

parent 8a297b43
...@@ -54,7 +54,9 @@ if (process.env.NODE_ENV === 'production') { ...@@ -54,7 +54,9 @@ if (process.env.NODE_ENV === 'production') {
}), }),
new SWPrecachePlugin({ new SWPrecachePlugin({
cacheId: 'vue-hn', cacheId: 'vue-hn',
filename: 'service-worker.js' filename: 'service-worker.js',
dontCacheBustUrlsMatching: /./,
staticFileGlobsIgnorePatterns: [/index\.html$/, /\.map$/]
}) })
) )
} }
......
{
"name": "Vue Hackernews 2.0",
"short_name": "Vue HN",
"icons": [{
"src": "/logo.png",
"sizes": "48x48",
"type": "image/png"
}],
"start_url": "/",
"background_color": "#f2f3f5",
"display": "standalone",
"theme_color": "#f60"
}
...@@ -4,7 +4,6 @@ const isProd = process.env.NODE_ENV === 'production' ...@@ -4,7 +4,6 @@ const isProd = process.env.NODE_ENV === 'production'
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const express = require('express') const express = require('express')
const favicon = require('serve-favicon')
const compression = require('compression') const compression = require('compression')
const serialize = require('serialize-javascript') const serialize = require('serialize-javascript')
const resolve = file => path.resolve(__dirname, file) const resolve = file => path.resolve(__dirname, file)
...@@ -50,8 +49,10 @@ function parseIndex (template) { ...@@ -50,8 +49,10 @@ function parseIndex (template) {
} }
app.use(compression({ threshold: 0 })) app.use(compression({ threshold: 0 }))
app.use('/dist', express.static(resolve('./dist'), { maxAge: isProd ? 60 * 60 * 24 * 30 : 0 })) const cacheConfig = { maxAge: isProd ? 60 * 60 * 24 * 30 : 0 }
app.use(favicon(resolve('./src/assets/logo.png'))) app.use('/dist', express.static(resolve('./dist'), cacheConfig))
app.use('/manifest.json', express.static(resolve('./manifest.json'), cacheConfig))
app.use('/logo.png', express.static(resolve('./src/assets/logo.png'), cacheConfig))
app.get('*', (req, res) => { app.get('*', (req, res) => {
if (!renderer) { if (!renderer) {
......
...@@ -38,6 +38,7 @@ a ...@@ -38,6 +38,7 @@ a
background-color #ff6600 background-color #ff6600
position fixed position fixed
z-index 999 z-index 999
height 55px
top 0 top 0
left 0 left 0
right 0 right 0
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>vue-hackernews-2.0</title> <title>vue-hackernews-2.0</title>
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<link rel="shortcut icon" sizes="48x48" href="/logo.png">
<meta name="theme-color" content="#f60">
<link rel="manifest" href="/manifest.json">
<link href='https://fonts.googleapis.com/css?family=Roboto:300,400,700' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Roboto:300,400,700' rel='stylesheet' type='text/css'>
</head> </head>
<body> <body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment