JSPM

  • Created
  • Published
  • Downloads 4115815
  • Score
    100M100P100Q209987F
  • License MIT

Vite resolver for TypeScript compilerOptions.paths

Package Exports

  • vite-tsconfig-paths

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vite-tsconfig-paths) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

vite-tsconfig-paths

npm Code style: Prettier Donate

Give vite the ability to resolve imports using TypeScript's path mapping.

Usage

  1. Install as dev dependency

  2. Inject vite-tsconfig-paths using the vite.config.ts module

    import type { UserConfig } from 'vite'
    import tsconfigPaths from 'vite-tsconfig-paths'
    
    const config: UserConfig = {
        plugins: [
            tsconfigPaths(),
        ],
    }
    
    export default config

Note: You need to restart Vite when you update your paths mappings.

Options

  • root: string
    The root directory to load tsconfig.json from.
    Defaults to viteConfig.root

  • extensions: string[]
    File extensions to search for.
    Defaults to .ts | .tsx | .js | .jsx | .json

  • loose: boolean
    Disable strictness that limits path resolution to TypeScript and JavaScript modules.
    Useful if you want asset URLs in Vue templates to be resolved.

 

checkJs

If your tsconfig.json file has "checkJs": true in it, path resolution will be expanded beyond TypeScript modules. The following extensions will have their imports resolved by this plugin: .vue, .svelte, .mdx, .mjs, .js, .jsx

 

If this package helps you, please donate! Any amount is greatly appreciated. 🥰

  • ETH: 0xa446626195bbe4d0697e729c1433a86fB6Cf66cF
  • BTC: 17vYtAUPKXzubMEnNcN8SiuFgicrd5Rp9A
  • KIN: GBU7RDRD7VDVT254RR6PGMBJESXQVDHJ5CGGODZKRXM2P4MP3G5QSAMH