Skip to content

Commit b7972b5

Browse files
kocopellykjclaude
authored
feat(bolt-vite-react-ts): add @/ path alias for src (#116)
* feat(bolt-vite-react-ts): add @/ path alias for src Configure a depth-invariant @/* -> src/* alias in both tsconfig.app.json (paths + baseUrl) and vite.config.ts (resolve.alias) so cross-module imports can be written @/services/foo instead of ../../services/foo. Removes the miscounted-relative-depth import errors that agents hit on deep folder layouts. * feat(bolt-vite-react-ts): steer imports to the @/ alias via template prompt Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: kj <kj@stackblitz.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3af8e29 commit b7972b5

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

bolt-vite-react-ts/.bolt/prompt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ For all designs I ask you to make, have them be beautiful, not cookie cutter. Ma
33
By default, this template supports JSX syntax with Tailwind CSS classes, React hooks, and Lucide React for icons. Do not install other packages for UI themes, icons, etc unless absolutely necessary or I request them.
44

55
Use icons from lucide-react for logos.
6+
7+
Import project modules with the `@/` path alias (`@/components/Foo`, maps to `src/`) instead of deep relative paths like `../../components/Foo`.

bolt-vite-react-ts/tsconfig.app.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
"noEmit": true,
1515
"jsx": "react-jsx",
1616

17+
/* Path alias — depth-invariant imports for src (@/foo === src/foo from any file) */
18+
"baseUrl": ".",
19+
"paths": {
20+
"@/*": ["src/*"]
21+
},
22+
1723
/* Linting */
1824
"strict": true,
1925
"noUnusedLocals": false,

bolt-vite-react-ts/vite.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
3+
import { fileURLToPath, URL } from 'node:url';
34

45
// https://vitejs.dev/config/
56
export default defineConfig({
67
plugins: [react()],
8+
resolve: {
9+
alias: {
10+
'@': fileURLToPath(new URL('./src', import.meta.url)),
11+
},
12+
},
713
optimizeDeps: {
814
exclude: ['lucide-react'],
915
},

0 commit comments

Comments
 (0)