Support snippets.html again

environments/review-main-yi2y9f/deployments/3931^2
Alex Gleason 2023-09-18 19:14:23 -05:00
rodzic 199d5d9f37
commit 95b7c62f67
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 17 dodań i 1 usunięć

Wyświetl plik

@ -8,6 +8,7 @@
<link href="/manifest.json" rel="manifest">
<!--server-generated-meta-->
<script type="module" src="./src/main.tsx"></script>
<%- snippets %>
</head>
<body class="theme-mode-light no-reduce-motion">
<div id="soapbox" class="h-full">

Wyświetl plik

@ -1,4 +1,5 @@
/// <reference types="vitest" />
import fs from 'node:fs';
import { fileURLToPath, URL } from 'node:url';
import react from '@vitejs/plugin-react';
@ -36,6 +37,11 @@ export default defineConfig({
collapseWhitespace: true,
removeComments: false,
},
inject: {
data: {
snippets: readFileContents('custom/snippets.html'),
},
},
}),
react({
// Use React plugin in all *.jsx and *.tsx files
@ -88,4 +94,13 @@ export default defineConfig({
environment: 'jsdom',
setupFiles: 'src/jest/test-setup.ts',
},
});
});
/** Return file as string, or return empty string if the file isn't found. */
function readFileContents(path: string) {
try {
return fs.readFileSync(path, 'utf8');
} catch {
return '';
}
}