DEV Community

Cover image for TIL how to set up path resolving in vite.
valbuena
valbuena

Posted on

TIL how to set up path resolving in vite.

What I Learned

[ is not set up by default. i wonder why.. ]

And why exactly is this interesting?

  1. [ because my imports look way sexier ]

vite.config.js

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
})
Enter fullscreen mode Exit fullscreen mode

Discussion (0)