Give Vite the ability to resolve nameof calls in TypeScript.
-
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
-
Inject
vite-plugin-ts-nameof
using thevite.config.ts
moduleimport 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()], });
-
Add
@typescript-nameof/types/index.d.cts
to yourtsconfig.json
{ // "compilerOptions" // "include" // ... "files": ["./node_modules/@typescript-nameof/types/index.d.cts"], }
Can be found here: Awesome Vite.js