Support snippets.html again
This commit is contained in:
parent
199d5d9f37
commit
95b7c62f67
2 changed files with 17 additions and 1 deletions
|
@ -8,6 +8,7 @@
|
||||||
<link href="/manifest.json" rel="manifest">
|
<link href="/manifest.json" rel="manifest">
|
||||||
<!--server-generated-meta-->
|
<!--server-generated-meta-->
|
||||||
<script type="module" src="./src/main.tsx"></script>
|
<script type="module" src="./src/main.tsx"></script>
|
||||||
|
<%- snippets %>
|
||||||
</head>
|
</head>
|
||||||
<body class="theme-mode-light no-reduce-motion">
|
<body class="theme-mode-light no-reduce-motion">
|
||||||
<div id="soapbox" class="h-full">
|
<div id="soapbox" class="h-full">
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/// <reference types="vitest" />
|
/// <reference types="vitest" />
|
||||||
|
import fs from 'node:fs';
|
||||||
import { fileURLToPath, URL } from 'node:url';
|
import { fileURLToPath, URL } from 'node:url';
|
||||||
|
|
||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react';
|
||||||
|
@ -36,6 +37,11 @@ export default defineConfig({
|
||||||
collapseWhitespace: true,
|
collapseWhitespace: true,
|
||||||
removeComments: false,
|
removeComments: false,
|
||||||
},
|
},
|
||||||
|
inject: {
|
||||||
|
data: {
|
||||||
|
snippets: readFileContents('custom/snippets.html'),
|
||||||
|
},
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
react({
|
react({
|
||||||
// Use React plugin in all *.jsx and *.tsx files
|
// Use React plugin in all *.jsx and *.tsx files
|
||||||
|
@ -89,3 +95,12 @@ export default defineConfig({
|
||||||
setupFiles: 'src/jest/test-setup.ts',
|
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 '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue