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:
Hans Pagel
2023-02-16 04:39:46 +01:00
committed by GitHub
parent 490d05b68b
commit e754f89e5c
40 changed files with 1646 additions and 3565 deletions

View File

@@ -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
);
});
}
});
}