generated from thzxcx/vue3
157 lines
3.8 KiB
TypeScript
157 lines
3.8 KiB
TypeScript
/*
|
|
* @Author: zhaojinfeng 121016171@qq.com
|
|
* @Date: 2023-06-15 13:22:04
|
|
* @LastEditors: peerless_hero peerless_hero@outlook.com
|
|
* @LastEditTime: 2023-07-11 02:55:29
|
|
* @FilePath: \uni\vite.config.ts
|
|
* @Description:
|
|
*
|
|
*/
|
|
import { URL, fileURLToPath } from 'node:url'
|
|
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
import libCss from 'vite-plugin-libcss'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import eslint from 'vite-plugin-eslint'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import setupExtend from 'vite-plugin-vue-setup-extend'
|
|
|
|
const reg = /[A-Z]/
|
|
function toLower(name: string) {
|
|
let lower = ''
|
|
for (let i = 0; i <= name.length - 1; i++) {
|
|
if (reg.test(name[i]))
|
|
lower += `-${name[i].toLowerCase()}`
|
|
else
|
|
lower += name[i]
|
|
}
|
|
return lower
|
|
}
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
export default defineConfig({
|
|
build: {
|
|
rollupOptions: {
|
|
external: ['vue', /\.sass/], // 排除三方包
|
|
output: {
|
|
globals: {
|
|
vue: 'Vue',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'~': fileURLToPath(new URL('./packages', import.meta.url)),
|
|
'@': fileURLToPath(new URL('./packages', import.meta.url)),
|
|
'/static': fileURLToPath(new URL('./assets/static', import.meta.url)),
|
|
},
|
|
},
|
|
plugins: [
|
|
vue(),
|
|
vueJsx(),
|
|
libCss({}),
|
|
AutoImport({
|
|
dts: 'types/auto-imports.d.ts',
|
|
imports: [
|
|
'vue',
|
|
'vue-router',
|
|
'uni-app',
|
|
'@vueuse/core',
|
|
{
|
|
vue: ['createVNode'],
|
|
},
|
|
],
|
|
vueTemplate: true,
|
|
}),
|
|
Components({
|
|
dts: 'types/components.d.ts',
|
|
dirs: ['dev', 'packages'],
|
|
types: [
|
|
{
|
|
from: '@uni-helper/uni-ui-types',
|
|
names: [
|
|
'UniBadge',
|
|
'UniBreadcrumb',
|
|
'UniBreadcrumbItem',
|
|
'UniCalendar',
|
|
'UniCard',
|
|
'UniCol',
|
|
'UniCollapse',
|
|
'UniCollapseItem',
|
|
'UniCombox',
|
|
'UniCountdown',
|
|
'UniDataCheckbox',
|
|
'UniDataPicker',
|
|
'UniDataSelect',
|
|
'UniDateformat',
|
|
'UniDatetimePicker',
|
|
'UniDrawer',
|
|
'UniEasyinput',
|
|
'UniFab',
|
|
'UniFav',
|
|
'UniFilePicker',
|
|
'UniForms',
|
|
'UniFormsItem',
|
|
'UniGoodsNav',
|
|
'UniGrid',
|
|
'UniGridItem',
|
|
'UniGroup',
|
|
'UniIcons',
|
|
'UniIndexedList',
|
|
'UniLink',
|
|
'UniList',
|
|
'UniListAd',
|
|
'UniListChat',
|
|
'UniListItem',
|
|
'UniLoadMore',
|
|
'UniNavBar',
|
|
'UniNoticeBar',
|
|
'UniNumberBox',
|
|
'UniPagination',
|
|
'UniPopup',
|
|
'UniPopupDialog',
|
|
'UniPopupMessage',
|
|
'UniPopupShare',
|
|
'UniRate',
|
|
'UniRow',
|
|
'UniSearchBar',
|
|
'UniSection',
|
|
'UniSegmentedControl',
|
|
'UniSteps',
|
|
'UniSwipeAction',
|
|
'UniSwipeActionItem',
|
|
'UniSwiperDot',
|
|
'UniTable',
|
|
'UniTag',
|
|
'UniTd',
|
|
'UniTh',
|
|
'UniTitle',
|
|
'UniTooltip',
|
|
'UniTr',
|
|
'UniTransition',
|
|
],
|
|
},
|
|
],
|
|
directoryAsNamespace: true,
|
|
resolvers: [
|
|
function (name) {
|
|
if (name.startsWith('Uni')) {
|
|
const componentName = toLower(name.slice(3))
|
|
return {
|
|
name: 'default',
|
|
as: name,
|
|
from: `@dcloudio/uni-ui/lib/uni${componentName}/uni${componentName}.vue`,
|
|
}
|
|
}
|
|
},
|
|
],
|
|
|
|
}),
|
|
setupExtend(),
|
|
eslint(),
|
|
],
|
|
})
|