77 lines
2.6 KiB
TypeScript
77 lines
2.6 KiB
TypeScript
import {defineConfig} from "vite";
|
|
import uni from "@dcloudio/vite-plugin-uni";
|
|
import {resolve} from 'path'
|
|
import autdPlugin from './plugin/vite-plugin-autd'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import AutoStylePlugin from "./plugin/vite-plugin-autoStyle";
|
|
import {HOMEAGENT} from "./src/config";
|
|
|
|
export default defineConfig({
|
|
base: './', // 添加这行,确保使用相对路径
|
|
server: {
|
|
proxy: {
|
|
"/base": {
|
|
target: HOMEAGENT,
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/base/, ""),
|
|
},
|
|
},
|
|
port: 5139,
|
|
host: true, // 允许外部访问
|
|
},
|
|
plugins: [
|
|
//c 为class 例如 class="wi-10"
|
|
//w 为样式style 例如 width:10rpx
|
|
//t 为值开头 例如 color:#000
|
|
//w 为值结尾 例如 width:10rpx
|
|
AutoStylePlugin([
|
|
{c: 'wi', s: 'width', t: '', w: 'rpx'},
|
|
{c: 'he', s: 'height', t: '', w: 'rpx'},
|
|
{c: 'cor', s: 'color', t: '#', w: ''},
|
|
{c: 'back', s: 'background', t: '#', w: ''},
|
|
{c: 'bor', s: 'border', t: '1px solid #', w: ''},
|
|
{c: 'gridCols', s: 'grid-template-columns', t: 'repeat(', w: ', minmax(0, 1fr))'},
|
|
{c: 'gridRows', s: 'grid-template-rows', t: 'repeat(', w: ', minmax(0, 1fr))'},
|
|
{c: 'gapY', s: 'grid-row-gap', t: '', w: 'rpx'},
|
|
{c: 'gapX', s: 'grid-column-gap', t: '', w: 'rpx'},
|
|
{c: 'colSpan', s: 'grid-column', t: 'span ', w: ''},
|
|
{c: 'rowSpan', s: 'grid-row', t: 'span ', w: ''},
|
|
]),
|
|
autdPlugin(),
|
|
uni({
|
|
vueOptions: {
|
|
template: {
|
|
compilerOptions: {
|
|
isCustomElement: tag => tag.startsWith("amap")
|
|
}
|
|
}
|
|
}
|
|
}),
|
|
AutoImport({
|
|
include: [
|
|
/\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
|
|
/\.vue$/, /\.vue\?vue/ // .vue
|
|
],
|
|
imports: ['vue', 'pinia'],
|
|
dts: "src/auto-import.d.ts" // 生成在src路径下名为auto-import.d.ts的声明文件
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': resolve(__dirname, './src'),
|
|
'#': resolve(__dirname, './types')
|
|
}
|
|
},
|
|
// 添加构建优化配置
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
'vendor': ['vue', 'pinia'],
|
|
'uni': ['@dcloudio/uni-app', '@dcloudio/uni-h5']
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|