This commit is contained in:
lei.jiang 2018-06-27 22:01:14 +08:00
parent 41ba52032d
commit 1583b6a5ce
6 changed files with 24 additions and 17 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -56,7 +56,8 @@ const devWebpackConfig = merge(baseWebpackConfig, {
inject: true,
favicon: resolve('favicon.ico'),
title: 'vue-element-admin',
path: config.dev.assetsPublicPath + config.dev.assetsSubDirectory
path: config.dev.assetsPublicPath + config.dev.assetsSubDirectory,
pwaPath: config.dev.assetsPublicPath
}),
]
})

View File

@ -152,6 +152,10 @@ const webpackConfig = merge(baseWebpackConfig, {
{
from: path.resolve(__dirname, '../manifest.json'),
to: config.build.assetsSubDirectory
},
{
from: path.resolve(__dirname, '../logo.png'),
to: config.build.assetsSubDirectory
}
])
]

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="manifest" href="<%= htmlWebpackPlugin.options.path %>/manifest.json">
<link rel="manifest" href="<%= htmlWebpackPlugin.options.pwaPath %>/manifest.json">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>vue-element-admin</title>
@ -15,7 +15,7 @@
</body>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('<%= htmlWebpackPlugin.options.path %>/sw.js').then(function(registration) {
navigator.serviceWorker.register('<%= htmlWebpackPlugin.options.pwaPath %>/sw.js').then(function(registration) {
// Registration Success
console.log('[serviceWorker]: registration successful with scope: ', registration.scope)
}).catch(function(err) {

View File

@ -3,8 +3,8 @@
"short_name": "VEAPWA",
"icons": [
{
"src": "../favicon.ico",
"sizes": "128x128",
"src": "./logo.png",
"sizes": "200x200",
"type": "image/png"
}
],

26
sw.js
View File

@ -4,21 +4,23 @@
const version = '2.0.0'
const CACHE = version + '::PWAsite'
const offlineURL = '/offline/'
const installFilesEssential = process.env.NODE_ENV === 'production' ? [
'/',
'../static/manifest.json',
'../static/css/*',
'../static/img/*',
'../static/js/*',
'../static/fonts/*',
'../static/tinymce4.7.5/*',
'../static/js/*'
].concat(offlineURL) : [
const installFilesEssential = [
'/',
'./static/manifest.json',
'./static/css/*',
'./static/img/*',
'./static/js/*',
'./static/fonts/*',
'./static/tinymce4.7.5/*',
'./manifest.json',
'./build/logo.png'
'./static/js/*',
'./logo.png'
].concat(offlineURL)
// const installFilesEssential = [
// '/',
// './static/tinymce4.7.5/*',
// './manifest.json',
// './build/logo.png'
// ].concat(offlineURL)
// install static assets
function installStaticFiles() {