mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
browser: inline sw register script
This commit is contained in:
parent
47d7644b72
commit
ce71ec1347
@ -5,7 +5,13 @@ import { extendTarget } from '../utils'
|
|||||||
import { SLSTarget } from '../config'
|
import { SLSTarget } from '../config'
|
||||||
import { worker } from './worker'
|
import { worker } from './worker'
|
||||||
|
|
||||||
const getScriptTag = () => '<script async defer src="/sw-register.js"></script>'
|
const getScriptTag = () => `<script>
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
window.addEventListener('load', function () {
|
||||||
|
navigator.serviceWorker.register('/server.js');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>`.replace(/\n| +/g, '')
|
||||||
|
|
||||||
export const browser: SLSTarget = extendTarget(worker, {
|
export const browser: SLSTarget = extendTarget(worker, {
|
||||||
targetDir: ({ publicDir }) => publicDir,
|
targetDir: ({ publicDir }) => publicDir,
|
||||||
|
Loading…
Reference in New Issue
Block a user