Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

//tsconfig.json
{
  "compilerOptions": {
    "paths": {
      //new config
      "@/*": ["./src/*"]
    }
  }
}
//vite.config.js
import tailwindcss from "@tailwindcss/vite";
import viteReact from "@vitejs/plugin-react";
import { defineConfig } from "vite";

import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
import tsconfigPaths from 'vite-tsconfig-paths'

// https://vitejs.dev/config/
export default defineConfig({
	plugins: [
               //tsconfigpath plugin
		tsconfigPaths(),
		TanStackRouterVite({ autoCodeSplitting: true }),
		viteReact(),
		tailwindcss(),
	
	],
	test: {
		globals: true,
		environment: "jsdom",
	},
});

so in the reguler code, we can just use alias path like this

import { Button } from "@/components/button";
You must be logged in to vote

Replies: 2 comments

Comment options

I agree. It's conditionally added with some add-ons, but might as well make it standard. I don't think it harms anything to have it. And the import paths look a lot cleaner.

You must be logged in to vote
0 replies
Comment options

Done!

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💡
Ideas
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.