VS Code Issue with Absolute Path

What I am trying to achieve is to create absolute path aliases in webpack to simplify importing modules. The code work as expected in Stackblitz web container https://stackblitz.com/edit/stackblitz-webcontainer-api-starter-u9g2us?file=package.json,src%2FApp.jsx,webpack%2Fwebpack.common.js But locally in vscode the code work aswell on webpack dev server, but vscode doesn't seem to realize the paths, I have no idea what's wrong? is it intellisense issue in vscode or what? Any help would be appreciated
No description
No description
2 Replies
dys 🐙
dys 🐙14mo ago
Paths within the current project have to start with something like ./ or ../. To refer to the project root, Vite (and I assume webpack, somehow) allow the creation of aliases like:
export default defineConfig({
resolve: {
alias: {
'@': path.join(__dirname, 'src'),
},
},
})
export default defineConfig({
resolve: {
alias: {
'@': path.join(__dirname, 'src'),
},
},
})
Would let you import stuff from your project as @/components/….
MohamedMostafa
MohamedMostafaOP14mo ago
Thank you. I just found a solution ( or a workaround idk 😂 ) but it worked. For reference check this comment https://github.com/facebook/create-react-app/issues/5645#issuecomment-435201019
Want results from more Discord servers?
Add your server