# vite2+vue3 **Repository Path**: fla126/vite2-vue3 ## Basic Information - **Project Name**: vite2+vue3 - **Description**: vite2+vue3 h5开发架构 - **Primary Language**: JavaScript - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 1 - **Created**: 2021-06-25 - **Last Updated**: 2021-09-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # vite2-h5 ## Project setup ``` yarn ``` ### Compiles and hot-reloads for development Node Version >= 12.0.0 [链接](https://github.com/facebook/create-react-app/issues/9273#issuecomment-658377736) ``` npm run dev ``` ### Compiles and minifies for production ``` npm run build ``` ### Preview production project ``` npm run serve ``` ### Customize configuration See [Configuration Reference](https://cli.vuejs.org/config/). ### 注意事项 ``` Vite2 的运行依赖于现代浏览器的import/export,因此vite编译之后的代码运行需要有http服务器支持,无法像webpack编译后的文件可以在文件系统直接打开预览 1. Vite2 是基于浏览器自带的Module功能,不依赖于nodejs,因此在组件导入导出时,只用 import/export 使用require无效,因require属于node函数。 2. 在导入Vue单文件组件时,一定要补全.vue的扩展名,否则不能正确导入组件。 3. 在引入图片资源时,不能在代码中使用 require('xxx.jpg'), 应在头部用 import xxx from 'xxx.jpg' 然后使用 4. Vite2构建的项目无法使用webpack中提供的 require.context 文件扫描功能,因此无法做到公共组件、状态、路由的自动化集成,用到的时候需要手动一一导入 ```