added path variable
This commit is contained in:
@@ -28,8 +28,14 @@ server {
|
||||
add_header Cache-Control "no-cache";
|
||||
}
|
||||
|
||||
# Single page app fallback.
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
try_files $uri $uri/ @prefixed;
|
||||
}
|
||||
|
||||
# The reverse proxy may forward a sub-path without stripping it (e.g. /website/static/x.js).
|
||||
# Drop the leading path segment and try again; fall back to the app's index.html.
|
||||
location @prefixed {
|
||||
rewrite ^/[^/]+(/.*)$ $1 last;
|
||||
rewrite ^ /index.html last;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,18 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<!-- Relative asset URLs need a trailing slash when served under a sub-path (/website -> /website/). -->
|
||||
<script>
|
||||
if (!/\/$|\.[a-z0-9]+$/i.test(location.pathname)) location.replace(location.pathname + '/' + location.search + location.hash);
|
||||
</script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="icon" type="image/svg+xml" href="/assets/favicon.svg" />
|
||||
<link rel="icon" type="image/svg+xml" href="./assets/favicon.svg" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet" />
|
||||
<title>Action Blocks</title>
|
||||
<!-- Runtime configuration, rewritten by the container on startup. -->
|
||||
<script src="/config.js"></script>
|
||||
<script src="./config.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
* (or point these paths elsewhere) to change the look without touching components.
|
||||
*/
|
||||
|
||||
/** Resolves a file in /public relative to where the site is served (works under sub-paths). */
|
||||
const asset = (path: string) => `${import.meta.env.BASE_URL}${path}`;
|
||||
|
||||
export interface ItemVisual {
|
||||
/** Icon drawn on board cells, in inventories and item bars. */
|
||||
icon: string;
|
||||
@@ -17,31 +20,31 @@ export interface ItemVisual {
|
||||
/** Keyed by the server item id (IItem.Id). Add an entry here when adding an item on the server. */
|
||||
export const itemVisuals: Record<string, ItemVisual> = {
|
||||
add_line: {
|
||||
icon: '/assets/items/add_line.svg',
|
||||
icon: asset('assets/items/add_line.svg'),
|
||||
name: 'Add Line',
|
||||
color: '#ff4256',
|
||||
description: 'Pushes a garbage line into the target field.',
|
||||
},
|
||||
clear_line: {
|
||||
icon: '/assets/items/clear_line.svg',
|
||||
icon: asset('assets/items/clear_line.svg'),
|
||||
name: 'Clear Line',
|
||||
color: '#4fe35f',
|
||||
description: 'Removes the bottom line of the target.',
|
||||
},
|
||||
nuke: {
|
||||
icon: '/assets/items/nuke.svg',
|
||||
icon: asset('assets/items/nuke.svg'),
|
||||
name: 'Wipe Out',
|
||||
color: '#ffe23f',
|
||||
description: 'Clears every placed block of the target.',
|
||||
},
|
||||
swap: {
|
||||
icon: '/assets/items/swap.svg',
|
||||
icon: asset('assets/items/swap.svg'),
|
||||
name: 'Switch',
|
||||
color: '#3fe3f2',
|
||||
description: 'Trades your whole field with the target.',
|
||||
},
|
||||
blind: {
|
||||
icon: '/assets/items/blind.svg',
|
||||
icon: asset('assets/items/blind.svg'),
|
||||
name: 'Blackout',
|
||||
color: '#c452ff',
|
||||
description: 'Hides placed blocks and the drop shadow for 4 seconds.',
|
||||
@@ -49,7 +52,7 @@ export const itemVisuals: Record<string, ItemVisual> = {
|
||||
};
|
||||
|
||||
export const unknownItem: ItemVisual = {
|
||||
icon: '/assets/items/unknown.svg',
|
||||
icon: asset('assets/items/unknown.svg'),
|
||||
name: 'Item',
|
||||
color: '#ffffff',
|
||||
description: '',
|
||||
@@ -58,7 +61,7 @@ export const unknownItem: ItemVisual = {
|
||||
export const uiAssets = {
|
||||
/** Optional logo image. When null the text logo is rendered. */
|
||||
logo: null as string | null,
|
||||
favicon: '/assets/favicon.svg',
|
||||
favicon: asset('assets/favicon.svg'),
|
||||
};
|
||||
|
||||
export function itemVisual(id: string): ItemVisual {
|
||||
|
||||
@@ -6,6 +6,8 @@ const devServer = process.env.DEV_SERVER_URL ?? 'http://localhost:5080';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
// Relative URLs so the site works under any sub-path (e.g. https://example.com/website/).
|
||||
base: './',
|
||||
build: {
|
||||
// Hashed bundles go to /static; /assets holds the exchangeable graphics from public/.
|
||||
assetsDir: 'static',
|
||||
|
||||
Reference in New Issue
Block a user