花大咩
花大咩
@akxcv I created the project `veaury`, solved all the problems, supports Vue3, supports vue and react components to share all contexts, supports using react hooks in vue components, and using...
@anhcuong203 OK, I will provide the typescript project examples of react and vue respectively
@anhcuong203 You can refer to this [Vue3 project](https://github.com/level-finance/frontend) and refer to the configuration of `babel.config.js`. The React components are imported into `src/pages/dashboard.vue`. The Vue3 project is a typescript project, so...
try `veaury`
try `veaury`
@Handpear 你是react的vite项目是吧?配置如下 `vite.config.js` ```js // vite.config.js import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' export default defineConfig({ plugins: [ react({...
> 似乎 vite 失去了对 ts 的编译能力? @Handpear 修改配置如下,记得安装`@vue/babel-plugin-jsx` 此配置会将`.vue`文件中的jsx以vuejsx解析,如果需要其他文件也进行vuejsx解析,在`overrides.incluede`里继续添加正则 ```js import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import vue from '@vitejs/plugin-vue' export default defineConfig({ plugins: [ vue(),...
@Handpear 升级到2.1.1版本 ```js import { defineConfig } from 'vite' // >= [email protected] import veauryVitePlugins from 'veaury/vite' export default defineConfig({ plugins: [ // 关闭 react plugin // react(), // 当type设置为react, //...
@Handpear 我最近回复的两个配置都能用的,最后一个配置只是把前一个配置包装了一下而已 是因为vueJsx插件会默认设置vite的esbuild的include为/\.ts/,也就是只让esbuild只处理ts文件的typescript编译,其他文件都默认走vueJsx插件使用babel的ts插件,但是比较可惜的是vueJsx的vite插件并没后设置enforce为pre,导致优先级不如react插件(因为react插件设置了enforce为pre),所以正确的配置是依旧使用react插件,但是预先把@vue/babel-plugin-jsx插入到react插件的plugins里(优先级最高,但是设置为关闭),然后就通过overrides来做条件的匹配选择是否开启vue的jsx编译即可
@Candidade vue3引入react,如果你是webpack,参考一下我的文档关于webpack的部分,应该使用veaury的babel插件