mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-16 11:50:42 +08:00
Fix statically replaced HASH_ROUTING env variables
Also moves the HASH_ROUTING env variable from being modified inside the hashRouter.spec.ts into the webserver config in the playwright.config.ipfs.ts Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
+1
-1
@@ -23,7 +23,7 @@
|
||||
if (!window.VITEST && !window.PLAYWRIGHT && import.meta.env.PROD) {
|
||||
const plausible = Plausible({
|
||||
domain: "app.radicle.xyz",
|
||||
hashMode: window.HASH_ROUTING,
|
||||
hashMode: import.meta.env.VITE_HASH_ROUTING,
|
||||
});
|
||||
|
||||
plausible.enableAutoPageviews();
|
||||
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
// Defined by vite or by custom passed env variables
|
||||
// Custom entries will be defined as globals during dev and statically replaced during build.
|
||||
interface ImportMeta extends Readonly<Record<string, unknown>> {
|
||||
env: {
|
||||
MODE: string;
|
||||
BASE_URL: string;
|
||||
PROD: boolean;
|
||||
DEV: boolean;
|
||||
SSR: boolean;
|
||||
VITE_HASH_ROUTING: boolean;
|
||||
};
|
||||
}
|
||||
Vendored
-1
@@ -8,7 +8,6 @@ declare global {
|
||||
// production.
|
||||
VITEST: boolean;
|
||||
PLAYWRIGHT: boolean;
|
||||
HASH_ROUTING: boolean;
|
||||
|
||||
// APP_CONFIG is set from within Playwright tests at runtime.
|
||||
// To better understand how it works together, have a look at:
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@ export const activeRouteStore: Readable<Route> = derived(
|
||||
},
|
||||
);
|
||||
|
||||
export const base = window.HASH_ROUTING ? "./" : "/";
|
||||
export const base = import.meta.env.VITE_HASH_ROUTING ? "./" : "/";
|
||||
|
||||
// Gets triggered when clicking on an anchor hash tag e.g. <a href="#header"/>
|
||||
// Allows the jump to a anchor hash
|
||||
@@ -97,7 +97,7 @@ export const push = (newRoute: Route): void => {
|
||||
// one subsequent pop() anyway.
|
||||
historyStore.set([...history, newRoute].slice(-10));
|
||||
|
||||
const path = window.HASH_ROUTING
|
||||
const path = import.meta.env.VITE_HASH_ROUTING
|
||||
? "#" + routeToPath(newRoute)
|
||||
: routeToPath(newRoute);
|
||||
|
||||
@@ -116,7 +116,7 @@ export const pop = (): void => {
|
||||
export function replace(newRoute: Route): void {
|
||||
historyStore.set([newRoute]);
|
||||
|
||||
const path = window.HASH_ROUTING
|
||||
const path = import.meta.env.VITE_HASH_ROUTING
|
||||
? "#" + routeToPath(newRoute)
|
||||
: routeToPath(newRoute);
|
||||
|
||||
@@ -142,7 +142,7 @@ function pathToRoute(path: string): Route | null {
|
||||
}
|
||||
|
||||
const url = new URL(path, window.origin);
|
||||
const segments = window.HASH_ROUTING
|
||||
const segments = import.meta.env.VITE_HASH_ROUTING
|
||||
? url.hash.substring(2).split("#")[0].split("/") // Try to remove any additional hashes at the end of the URL.
|
||||
: url.pathname.substring(1).split("/");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user