browser: inline sw register script

This commit is contained in:
Pooya Parsa 2020-11-06 10:57:04 +01:00
parent 47d7644b72
commit ce71ec1347

View File

@ -5,7 +5,13 @@ import { extendTarget } from '../utils'
import { SLSTarget } from '../config'
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, {
targetDir: ({ publicDir }) => publicDir,