import { defineConfig } from 'vite'; import uni from "@dcloudio/vite-plugin-uni"; import AutoImport from 'unplugin-auto-import/vite'; import Components from 'unplugin-vue-components/vite'; export default defineConfig({ plugins: [ uni(), // 自动导入 Vue 相关 API(如 ref, reactive) AutoImport({ imports: ['vue', { '@dcloudio/uni-app': [ 'onLoad', // 页面加载时触发 'onShow', // 页面显示时触发 'onHide', // 页面隐藏时触发 'onUnload', // 页面卸载时触发 ], }, { '@/common/utils': [ 'showToast', // 明确列出方法名(推荐) 'sleep', ], }, { '@/common/yds': [ ['yds'], // 从 '@/common/index' 导入 yds 对象 ], } ], }), // 自动导入组件 Components({ dirs: [ 'components/youdas-container', 'components/uni-nav-bar', // 'components/uni-popup', // 'components/uni-transition' ], // 指定组件目录 extensions: ['vue'], dts: true, // 生成类型声明文件(可选) // resolvers: [ // (name) => { // if (name === 'uni-popup') { // 匹配 kebab-case 名称 // return { // importName: 'uni-popup', // 组件文件实际导出的名称 // path: '@/components/uni-popup/components/uni-popup/uni-popup.vue', // 文件路径 // kebabCase: true // } // } // } // ] }), ], build: { minify: 'terser', terserOptions: { compress: { drop_console: true, }, }, } });