Open layzf opened 3 months ago
遇到一个奇怪的问题: 1.在src/config/env.ts中使用import.meta.env.MODE无法正常编译,其他文件可以使用。 2.在src/config/env.ts中使用uni的API无法正常编译(uni is not defined),其他文件可以使用。
如果没有开发h5端的需求的话,可以把 https://github.com/ttk-cli/uni-vue3-vite-ts-pinia/blob/f0d960b2d590a7f3af3503c7ce35796e88b3d623/vite.config.ts#L10 和 https://github.com/ttk-cli/uni-vue3-vite-ts-pinia/blob/f0d960b2d590a7f3af3503c7ce35796e88b3d623/vite.config.ts#L44-L56 去掉
在 vite.config.ts 中导入env文件是为了设置 h5 开发环境的代理(小程序和app不需要设置),因为 import.meta.env.MODE 和 uni 在编译阶段是不存在的,所以在这个文件中使用会报错
遇到一个奇怪的问题: 1.在src/config/env.ts中使用import.meta.env.MODE无法正常编译,其他文件可以使用。 2.在src/config/env.ts中使用uni的API无法正常编译(uni is not defined),其他文件可以使用。