Skip to content

Commit 1dc524f

Browse files
committed
Move index.html to public/ with custom Vite root
Configure Vite to use public/ as the project root, allowing index.html to reside in the same directory as other static assets. Changes: - Move index.html from project root to public/ - Set vite.config.ts root: 'public' - Disable publicDir since we're using public/ as root - Update build.outDir to '../build' (relative to public/) - Update test.setupFiles and test.include paths for Vitest - Update index.html script src to '../src/index.tsx' This configuration: - Keeps index.html with static assets in public/ - Maintains src/ at project root - Preserves all existing functionality - All tests passing (61 tests) - Build and lint verified working
1 parent 08224d1 commit 1dc524f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

index.html renamed to public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
<body>
1717
<noscript>You need to enable JavaScript to run this app.</noscript>
1818
<div id="root"></div>
19-
<script type="module" src="/src/index.tsx"></script>
19+
<script type="module" src="../src/index.tsx"></script>
2020
</body>
2121
</html>

vite.config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import viteTsconfigPaths from 'vite-tsconfig-paths'
44

55
// https://vite.dev/config/
66
export default defineConfig({
7+
root: 'public',
8+
publicDir: false, // Disable default public dir since we're using public as root
79
plugins: [
810
react(),
911
viteTsconfigPaths(),
@@ -13,12 +15,14 @@ export default defineConfig({
1315
open: true,
1416
},
1517
build: {
16-
outDir: 'build',
18+
outDir: '../build',
19+
emptyOutDir: true,
1720
sourcemap: true,
1821
},
1922
test: {
2023
globals: true,
2124
environment: 'jsdom',
22-
setupFiles: './src/setupTests.ts',
25+
setupFiles: '../src/setupTests.ts',
26+
include: ['../src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
2327
},
2428
})

0 commit comments

Comments
 (0)