# vite-plugin-vue3-define-reactive **Repository Path**: zplan/vite-plugin-vue3-define-reactive ## Basic Information - **Project Name**: vite-plugin-vue3-define-reactive - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-03-14 - **Last Updated**: 2024-03-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # vite-plugin-vue3-define-reactive a special compiler macros `defineReactive` for `vue3 script-setup` ## without ```javascript ``` ## with example 1: ```javascript ``` ## without ```javascript ``` ## with example 2: ```javascript ``` #### In fact, your code will transform before vue complie: ### example 1: ```javascript ``` ### example 2: ```javascript ``` ## Usage ```shell yarn add vite-plugin-vue3-define-reactive or npm install vite-plugin-vue3-define-reactive ``` In your `vite.config.js`: ```javascript import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import defineReactive from 'vite-plugin-vue3-define-reactive' export default defineConfig({ plugins: [ defineReactive(), vue() ], }) ``` ### type Create a new file in your src folder and write this for type hints. ```javascript declare global { const defineReactive:(obj:T)=>T } export {} ``` ### by the way if before `script-setup version` you write vue3 code like this: ```javascript import { toRefs,reactive } from 'vue'; ``` this is helpful for refactor you project to `script-setup`: ```javascript ```