youdas/vite.config.js
2025-06-22 14:22:22 +08:00

64 lines
2.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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,
},
},
}
});