增加pwa判断环境
This commit is contained in:
parent
3cd673b9af
commit
41ba52032d
|
@ -144,6 +144,14 @@ const webpackConfig = merge(baseWebpackConfig, {
|
|||
from: path.resolve(__dirname, '../static'),
|
||||
to: config.build.assetsSubDirectory,
|
||||
ignore: ['.*']
|
||||
},
|
||||
{
|
||||
from: path.resolve(__dirname, '../sw.js'),
|
||||
to: config.build.assetsSubDirectory
|
||||
},
|
||||
{
|
||||
from: path.resolve(__dirname, '../manifest.json'),
|
||||
to: config.build.assetsSubDirectory
|
||||
}
|
||||
])
|
||||
]
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<link rel="manifest" href="./manifest.json">
|
||||
<link rel="manifest" href="<%= htmlWebpackPlugin.options.path %>/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('sw.js').then(function(registration) {
|
||||
navigator.serviceWorker.register('<%= htmlWebpackPlugin.options.path %>/sw.js').then(function(registration) {
|
||||
// Registration Success
|
||||
console.log('[serviceWorker]: registration successful with scope: ', registration.scope)
|
||||
}).catch(function(err) {
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
"short_name": "VEAPWA",
|
||||
"icons": [
|
||||
{
|
||||
"src": "./build/logo.png",
|
||||
"sizes": "200x200",
|
||||
"src": "../favicon.ico",
|
||||
"sizes": "128x128",
|
||||
"type": "image/png"
|
||||
}
|
||||
],
|
||||
"start_url": "http://localhost:9527",
|
||||
"start_url": "/PWA/",
|
||||
"display": "standalone",
|
||||
"background_color": "#2d3a4b",
|
||||
"theme_color": "#3d5165"
|
||||
|
|
14
sw.js
14
sw.js
|
@ -4,12 +4,18 @@
|
|||
const version = '2.0.0'
|
||||
const CACHE = version + '::PWAsite'
|
||||
const offlineURL = '/offline/'
|
||||
const installFilesEssential = [
|
||||
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) : [
|
||||
'/',
|
||||
'./static/tinymce4.7.5/*',
|
||||
// './dist/css/*',
|
||||
// './dist/fonts/*',
|
||||
// './dist/img/*',
|
||||
'./manifest.json',
|
||||
'./build/logo.png'
|
||||
].concat(offlineURL)
|
||||
|
|
Loading…
Reference in New Issue