forked from mystiq/hydrogen-web
load service worker in production mode, adjust development flag
This commit is contained in:
parent
bc86bf2d00
commit
9a3f74c6fb
2 changed files with 8 additions and 2 deletions
|
@ -19,18 +19,21 @@
|
||||||
import {main} from "./main";
|
import {main} from "./main";
|
||||||
import {Platform} from "./Platform";
|
import {Platform} from "./Platform";
|
||||||
import configJSON from "./assets/config.json?raw";
|
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 = {
|
const paths = {
|
||||||
olm: olmPaths,
|
olm: olmPaths,
|
||||||
downloadSandbox: downloadSandboxPath,
|
downloadSandbox: downloadSandboxPath,
|
||||||
worker: workerPath,
|
worker: workerPath,
|
||||||
...JSON.parse(configJSON)
|
...JSON.parse(configJSON)
|
||||||
};
|
};
|
||||||
|
if (import.meta.env.PROD) {
|
||||||
|
paths.serviceWorker = serviceWorkerPath;
|
||||||
|
}
|
||||||
const platform = new Platform(
|
const platform = new Platform(
|
||||||
document.body,
|
document.body,
|
||||||
paths,
|
paths,
|
||||||
null,
|
null,
|
||||||
{development: true}
|
{development: import.meta.env.DEV}
|
||||||
);
|
);
|
||||||
main(platform);
|
main(platform);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -17,3 +17,6 @@ export const olmPaths = {
|
||||||
|
|
||||||
export const downloadSandboxPath = _downloadSandboxPath;
|
export const downloadSandboxPath = _downloadSandboxPath;
|
||||||
export const workerPath = _workerPath;
|
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";
|
||||||
|
|
Loading…
Reference in a new issue