vite-plugin-typescript-path-aliases
v0.0.3
Published
Simple vite plugin to generate typescript path mapping based on vite aliases
Downloads
3
Readme
Simple vite plugin to generate typescript path mapping base on vite aliases
Install
npm i --save-dev vite-plugin-typescript-path-aliases
// tsconfig.json
{
"extends": ["vite-plugin-typescript-path-aliases/paths"]
}
// vite.config
import { defineConfig } from 'vite';
import { fileURLToPath } from 'node:url';
import { typescriptPathAliases } from 'vite-plugin-typescript-path-aliases';
export default defineConfig({
plugins: [typescriptPathAliases()],
resolve: {
alias: [
{
find: '@example',
replacement: fileURLToPath(new URL('src', import.meta.url)),
},
],
},
});
Note: You need to restart vite to apply the changes
Now you can import files as
import myFile from '@example/my-file';