Skip to content

Commit

Permalink
Set up absolute imports to work at compile-time
Browse files Browse the repository at this point in the history
  • Loading branch information
mfisher87 committed Jul 10, 2024
1 parent 5328381 commit d29350e
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 9 deletions.
51 changes: 50 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"eslint-plugin-react-refresh": "^0.4.7",
"husky": "^9.0.11",
"typescript": "^5.2.2",
"vite": "^5.3.1"
"vite": "^5.3.1",
"vite-tsconfig-paths": "^4.3.2"
}
}
3 changes: 3 additions & 0 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"compilerOptions": {
"paths": {
"@src/*": ["./src/*"]
},
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"skipLibCheck": true,
Expand Down
14 changes: 7 additions & 7 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { defineConfig } from 'vite'

import react from '@vitejs/plugin-react-swc'
import tsconfigPaths from 'vite-tsconfig-paths'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
// "Absolute imports":
resolve: {
alias: {
"@src": "/src",
},
},
plugins: [
react(),
// We use this for "absolute imports":
tsconfigPaths(),
],
})

0 comments on commit d29350e

Please sign in to comment.