From d0492dbd7dccf704be589622c0eef24ed48289ba Mon Sep 17 00:00:00 2001 From: ridhlab Date: Tue, 26 Dec 2023 17:14:51 +0700 Subject: [PATCH] chore: implement absolute import --- tsconfig.json | 8 +++++++- vite.config.ts | 14 ++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index a7fc6fb..50d434d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,7 +18,13 @@ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + + /* Path */ + "baseUrl": "./src", + "paths": { + "@/*": ["./*"] + } }, "include": ["src"], "references": [{ "path": "./tsconfig.node.json" }] diff --git a/vite.config.ts b/vite.config.ts index 861b04b..a4270f0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,13 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react-swc' +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react-swc"; +import path from "path"; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react()], -}) + plugins: [react()], + resolve: { + alias: { + "@": path.resolve(__dirname, "./src"), + }, + }, +});