Just started working again with Visual studio code after years on PHPStorm/Webstorm
I've decided to take the transition just because of how lightweight VSCode is and because I don't want to rely on a paid service/having it on every computer since VSCode is almost everywhere and free.
I started fresh
Vite + Vue3
Now I've come across several issues with Imports CTRL+Click - goto reference Autocompletes
my Vite.config is as follows - to enable aliases
import { defineConfig } from "vite";
import { fileURLToPath, URL } from "url";
import vue from "@vitejs/plugin-vue";
import path from "path";
// https://vitejs.dev/config/
/// <reference types="vitest" />
export default defineConfig({
resolve: {
extensions: [".js", ".json", ".vue", ".scss", ".css"],
fallback: {
crypto: path.resolve("crypto-browserify"),
stream: path.resolve("stream-browserify"),
},
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
img: path.resolve(__dirname, "./public/img"),
},
},
plugins: [vue()],
test: {},
server: {
port: 8080,
},
build: {
sourcemap: false,
minify: false,
assetsDir: "chunks",
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "sass:math"; @import "./src/assets/scss/v2/legacy.scss"; @import "./src/assets/scss/common.scss";`,
},
},
},
});
Now, with vite config alone I can import using the "@" alias - but no intellisense is taking place, I can't autocomplete imports nor can I ctrl + click
After adding a jsconfig.json file
{
"compilerOptions": {
"target": "ESNext",
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}
}
I am now able to import my components using the "@" and also have full intellisense on them and can CTRL+click them BUT, now I've lost the ability to import node_modules - lost all intellisense on that
So, if I use my vite/jsconfig I can ctrl+click/have auto complete on "@" alias but I lost my node_module import capabilities
If I remove those vite.config alias configuration and remove jsconfig I get back node_module intellisense and lost my project's intellisense.
What am I missing here? please help me figure this out.
I've also removed any / every npm import extension just so that I can understand how this works