Absolute Import is a great way to clean up your imports
Setting up absolute imports can be a lot of pain to search on the internet, I spend quit...
For further actions, you may consider blocking this person and/or reporting abuse
Wasn't this enough? No need to add an entry everytime you create a folder.
Oh cool, just tried it and it works on Next.js, I remember it has some issue for the F12 look up but I think there is no problem now! Thanks for your addition, updated the blog.
It kinda messes with CRA auto import using that approach, will update if I found anything.
i have two jsconfig.json flie in my project one is for my reactjs and one is for my nodejs project
and it is always good to use special character before the folder path
the config i user for my backend :-
Looks good but I think tilde-slash prefix (
~/
) shouldn't be used for project-scoped aliases.~/
means home directory for current user on unix-like systems. So, it is looking like an absolute path to me at the first glance.Great article.
Would it be possible to configure vite to understand absolute path WITHOUT using a prefix like (@)?
My vite project is created as React JS (not TS).
Previously with CRA + WebPack, I was able to specify this:
where my jsconfig.json looks like this:
If you are facing "Dynamic required of 'path' is not supported" error in vite.config.js replace
const path = require('path')
withimport * as path from 'path'
this will fix the issueand
@vitejs/plugin-react-refresh
is deprecated useimport react from "@vitejs/plugin-react"
instud.Sorry but what's wrong with?
It's really just preference
@vitejs/plugin-react-refresh
is deprecated, maybe consider updating the article and removing it?Hii bro" i have fixed for new problem on React Vite without TS, just just chillin add ./ before src on alias (vite.config.js), and it will solve your problem.
Awesome article bro, very helpful, thanks for sharing!
How to implement this in typescript? Do I just edit the tsconfig.json?
Yes. That would take care of it.
This does not help with syntax highlighting, right?
For Create React App without using Craco in latest version (v5.0.1) , absolute import doesn't work. it's a bug. please revise the post. github.com/facebook/create-react-a...
I'm getting a MIME not allowed error when I change filepath to '@/filepath'
React JS + Vite