vite-plugin-ts-nameof

Give Vite the ability to resolve 'nameof' calls in TypeScript

Usage no npm install needed!

<script type="module">
  import vitePluginTsNameof from 'https://cdn.skypack.dev/vite-plugin-ts-nameof';
</script>

README

vite-plugin-ts-nameof

license: MIT NPM package downloads Code style: Prettier Awesome Build Status

Give Vite the ability to resolve nameof calls in TypeScript.

Usage

  1. Install as devDependencies

    npm add --save-dev vite-plugin-ts-nameof
    # or
    yarn add --dev vite-plugin-ts-nameof
    # or
    pnpm add --save-dev vite-plugin-ts-nameof
    
  2. Inject vite-plugin-ts-nameof using the vite.config.ts module

    import vue from '@vitejs/plugin-vue';
    import { defineConfig } from 'vite';
    import tsNameof from 'vite-plugin-ts-nameof';
    
    // https://vitejs.dev/config/
    export default defineConfig({
      plugins: [tsNameof(), vue()],
    });
    
  3. Add ts-nameof.d.ts to your tsconfig.json

    {
      // "compilerOptions"
      // "include"
      // ...
      "files": ["./node_modules/ts-nameof/ts-nameof.d.ts"]
    }
    

More Awesome Vite Plugins

Can be found here: Awesome Vite.js