为什么脱机先不在polymer2中工作
我不明白为什么脱机首先不在Polymer2中工作。这是我的为什么脱机先不在polymer2中工作,polymer,polymer-1.0,polymer-starter-kit,polymer-2.x,Polymer,Polymer 1.0,Polymer Starter Kit,Polymer 2.x,我不明白为什么脱机首先不在Polymer2中工作。这是我的sw precache config.js和polymer.json module.exports = { staticFileGlobs: [ '/index.html', '/manifest.json', '/bower_components/webcomponentsjs/webcomponents-loader.js', '/images/*' ], navigateFallback:
sw precache config.js
和polymer.json
module.exports = {
staticFileGlobs: [
'/index.html',
'/manifest.json',
'/bower_components/webcomponentsjs/webcomponents-loader.js',
'/images/*'
],
navigateFallback: '/index.html',
navigateFallbackWhitelist: [/^(?!.*\.html$|\/data\/).*/],
runtimeCaching: [
{
urlPattern: /\/bower_components\/webcomponentsjs\/.*.js/,
handler: 'fastest',
options: {
cache: {
name: 'webcomponentsjs-polyfills-cache'
}
}
},
{
urlPattern: /\/data\/images\/.*/,
handler: 'cacheFirst',
options: {
cache: {
maxEntries: 200,
name: 'items-cache'
}
}
},
{
urlPattern: /\/data\/.*json/,
handler: 'fastest',
options: {
cache: {
maxEntries: 100,
name: 'data-cache'
}
}
}
]
};
polymer.json
{
"entrypoint": "index.html",
"shell": "src/my-app.html",
"fragments": [
"src/my-home.html",
"src/my-category.html",
"src/my-company.html",
"src/my-courses.html",
"src/my-view404.html"
],
"sources": [
"src/**/*",
"data/**/*",
"images/**/*",
"bower.json"
],
"extraDependencies": [
"manifest.json",
"bower_components/webcomponentsjs/*.js"
],
"lint": {
"rules": ["polymer-2"]
},
"builds": [{
"name": "bundled",
"addServiceWorker": true,
"bundle": true,
"js": {"minify": false, "compile": false},
"css": {"minify": false},
"html": {"minify": false}
},{
"name": "unbundled",
"addServiceWorker": true,
"bundle": false,
"js": {"minify": true, "compile": true},
"css": {"minify": true},
"html": {"minify": true}
}]
}
请告诉我为什么它根本不起作用?您必须将“swPrecacheConfig”:“sw precache config.js”
添加到每个“build”
数组项中,以包括您的服务人员。
另外,请注意,开发(
polymer-serve
)环境(未构建)绕过了服务人员注册。您所说的“不工作”是什么意思?请具体说明。为什么我关闭了wifi或internet,它将无法显示页面而不是显示缓存。这是你的应用程序的链接吗?它看起来不像是正在加载和运行服务工作者。是starter kit中加载服务人员(如果浏览器支持)的行。