override entrypoint, automatically load serviceworker

This commit is contained in:
notgne2 2019-12-23 16:08:37 -07:00
parent aeebfd82db
commit 31cb962156
2 changed files with 9 additions and 1 deletions

View File

@ -155,7 +155,8 @@ let
<meta name="msapplication-config" content="/appdata/browserconfig.xml"> <meta name="msapplication-config" content="/appdata/browserconfig.xml">
<meta name="theme-color" content="${themeColor}"> <meta name="theme-color" content="${themeColor}">
</head> </head>
<body></body> <body>
</body>
</html> </html>
''; '';
in in

View File

@ -75,6 +75,13 @@ prerenderOpts = (width, height, name) => ({
module.exports = { module.exports = {
target: 'web', target: 'web',
entry: magicFile(`
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => navigator.serviceWorker.register('/sw.js'));
}
require('${process.env.PWD}/src/index.js')
`),
output: { output: {
filename: 'main.js', filename: 'main.js',
path: path.join(__dirname, 'dist'), path: path.join(__dirname, 'dist'),