Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure TypeScript Paths #11

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';
import './index.css';
import App from '@/App.tsx';
import '@/index.css';

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
Expand Down
5 changes: 5 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
"module": "ESNext",
"skipLibCheck": true,

/*Configure TypeScript Paths*/
"paths": {
"@/*": ["./src/*"],
},

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
Expand Down
13 changes: 12 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';

// https://vitejs.dev/config/
// vite.config.ts
export default defineConfig({
plugins: [react()],
server: {
Expand All @@ -17,4 +18,14 @@ export default defineConfig({
environment: 'jsdom',
setupFiles: ['./src/__test__/setupTests.ts'],
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
rollupOptions: {
external: ['src/App.tsx'],
},
},
});
Loading