DEV Community 👩‍💻👨‍💻

Discussion on: How to add module import aliases in SvelteKit

Collapse
 
patricknelson profile image
Patrick Nelson

Wanted to add $components and this absolutely works like a charm, thank you. Vite really is awesome!

Also, if you're using WebStorm like me (or a WebStorm variant like PhpStom), you can also enable the IDE's ability to resolve those special $lib/* paths (and whatever other custom aliases you setup) by a .js file in the root of your project which calls an undocumented System.config() function that tells WebStorm how where to find them:

// eslint-disable
System.config({
  "paths": {
    "$lib/*": "./src/lib/*",
    "$components/*": "./src/lib/components/*",
  }
});
Enter fullscreen mode Exit fullscreen mode

I expand a bit more on this in a self-answered StackOverflow post here.