zhxy-jzd/vite.config.ts

76 lines
2.6 KiB
TypeScript
Raw Permalink Normal View History

2025-04-30 01:43:23 +08:00
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({
server: {
proxy: {
"/base": {
target: HOMEAGENT,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/base/, ""),
},
},
port: 5139,
2025-04-30 01:43:23 +08:00
},
2025-12-24 19:45:48 +08:00
build: {
// 确保文件名包含 hash便于缓存失效控制
rollupOptions: {
output: {
entryFileNames: `assets/[name]-[hash].js`,
chunkFileNames: `assets/[name]-[hash].js`,
assetFileNames: `assets/[name]-[hash].[ext]`,
}
},
// 生成 manifest 方便版本追踪
manifest: true,
},
2025-04-30 01:43:23 +08:00
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')
}
}
});