Replace Webpack with Vite (#4765)
Co-authored-by: Tom Moor <tom@getoutline.com> Co-authored-by: Vio <vio@beanon.com>
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
import "vite/modulepreload-polyfill";
|
||||
import "focus-visible";
|
||||
import "setimmediate";
|
||||
import { LazyMotion } from "framer-motion";
|
||||
import { KBarProvider } from "kbar";
|
||||
import { Provider } from "mobx-react";
|
||||
@@ -35,33 +38,6 @@ if (env.SENTRY_DSN) {
|
||||
initSentry(history);
|
||||
}
|
||||
|
||||
if ("serviceWorker" in window.navigator) {
|
||||
window.addEventListener("load", () => {
|
||||
// see: https://bugs.chromium.org/p/chromium/issues/detail?id=1097616
|
||||
// In some rare (<0.1% of cases) this call can return `undefined`
|
||||
const maybePromise = window.navigator.serviceWorker.register(
|
||||
"/static/service-worker.js",
|
||||
{
|
||||
scope: "/",
|
||||
}
|
||||
);
|
||||
|
||||
if (maybePromise?.then) {
|
||||
maybePromise
|
||||
.then((registration) => {
|
||||
Logger.debug("lifecycle", "SW registered: ", registration);
|
||||
})
|
||||
.catch((registrationError) => {
|
||||
Logger.debug(
|
||||
"lifecycle",
|
||||
"SW registration failed: ",
|
||||
registrationError
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Make sure to return the specific export containing the feature bundle.
|
||||
const loadFeatures = () => import("./utils/motion").then((res) => res.default);
|
||||
|
||||
@@ -116,13 +92,38 @@ window.addEventListener("load", async () => {
|
||||
return;
|
||||
}
|
||||
// https://github.com/googleanalytics/autotrack/issues/137#issuecomment-305890099
|
||||
await import(
|
||||
/* webpackChunkName: "autotrack" */
|
||||
"autotrack/autotrack.js"
|
||||
);
|
||||
await import("autotrack/autotrack.js");
|
||||
window.ga("require", "outboundLinkTracker");
|
||||
window.ga("require", "urlChangeTracker");
|
||||
window.ga("require", "eventTracker", {
|
||||
attributePrefix: "data-",
|
||||
});
|
||||
});
|
||||
|
||||
if ("serviceWorker" in navigator) {
|
||||
window.addEventListener("load", () => {
|
||||
// see: https://bugs.chromium.org/p/chromium/issues/detail?id=1097616
|
||||
// In some rare (<0.1% of cases) this call can return `undefined`
|
||||
const maybePromise = navigator.serviceWorker.register("/static/sw.js", {
|
||||
scope: "/",
|
||||
});
|
||||
|
||||
if (maybePromise?.then) {
|
||||
maybePromise
|
||||
.then((registration) => {
|
||||
Logger.debug(
|
||||
"lifecycle",
|
||||
"[ServiceWorker] Registered.",
|
||||
registration
|
||||
);
|
||||
})
|
||||
.catch((registrationError) => {
|
||||
Logger.debug(
|
||||
"lifecycle",
|
||||
"[ServiceWorker] Registration failed.",
|
||||
registrationError
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user