Skip to content

Shinigami92/vite-plugin-ts-nameof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Feb 25, 2024
042549b · Feb 25, 2024
Feb 25, 2024
Mar 1, 2022
Feb 25, 2024
Feb 25, 2024
Mar 1, 2022
Feb 25, 2024
Aug 31, 2021
Jun 16, 2023
Feb 25, 2024
Feb 25, 2024
Feb 25, 2024
Feb 25, 2024
Feb 25, 2024
Feb 25, 2024
Feb 25, 2024
Jun 16, 2023

Repository files navigation

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 @typescript-nameof/types @typescript-nameof/common-types
    # or
    pnpm add --save-dev vite-plugin-ts-nameof @typescript-nameof/types @typescript-nameof/common-types
    # or
    yarn add --dev vite-plugin-ts-nameof @typescript-nameof/types @typescript-nameof/common-types
  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 @typescript-nameof/types/index.d.cts to your tsconfig.json

    {
      // "compilerOptions"
      // "include"
      // ...
      "files": ["./node_modules/@typescript-nameof/types/index.d.cts"],
    }

More Awesome Vite Plugins

Can be found here: Awesome Vite.js