load service worker in production mode, adjust development flag

This commit is contained in:
Bruno Windels 2021-12-03 10:42:38 +01:00
parent bc86bf2d00
commit 9a3f74c6fb
2 changed files with 8 additions and 2 deletions

View File

@ -19,18 +19,21 @@
import {main} from "./main";
import {Platform} from "./Platform";
import configJSON from "./assets/config.json?raw";
import {olmPaths, downloadSandboxPath, workerPath} from "./sdk/paths/vite";
import {olmPaths, downloadSandboxPath, workerPath, serviceWorkerPath} from "./sdk/paths/vite";
const paths = {
olm: olmPaths,
downloadSandbox: downloadSandboxPath,
worker: workerPath,
...JSON.parse(configJSON)
};
if (import.meta.env.PROD) {
paths.serviceWorker = serviceWorkerPath;
}
const platform = new Platform(
document.body,
paths,
null,
{development: true}
{development: import.meta.env.DEV}
);
main(platform);
</script>

View File

@ -17,3 +17,6 @@ export const olmPaths = {
export const downloadSandboxPath = _downloadSandboxPath;
export const workerPath = _workerPath;
// the service worker is generated by the build as an unhashed asset,
// we don't use it at development time, so don't use import for the path
export const serviceWorkerPath = "sw.js";