mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-28 00:22:05 +00:00
21 lines
699 B
JavaScript
21 lines
699 B
JavaScript
if (process.BROWSER_BUILD && process.env.NODE_ENV === 'production') {
|
|
require('offline-plugin/runtime').install()
|
|
window.onNuxtReady((app) => {
|
|
if ('serviceWorker' in navigator) {
|
|
if (navigator.serviceWorker.controller) {} else {
|
|
navigator.serviceWorker.register('/sw.js').then(function(res) {
|
|
console.log('sw loaded...')
|
|
}).catch(function(err) {
|
|
console.log(err);
|
|
});
|
|
}
|
|
} else if (window.applicationCache) {
|
|
// register appcache code
|
|
var iframe = document.createElement('iframe');
|
|
iframe.style.display = "none";
|
|
iframe.src = '/appcache/manifest.html';
|
|
document.body.appendChild(iframe);
|
|
}
|
|
})
|
|
}
|