59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
|
|
import { resolve } from 'node:path'
|
|||
|
|
import { fileURLToPath, URL } from 'node:url'
|
|||
|
|
|
|||
|
|
import { defineConfig } from 'vite'
|
|||
|
|
import vue from '@vitejs/plugin-vue'
|
|||
|
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
|||
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|||
|
|
import Components from 'unplugin-vue-components/vite'
|
|||
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
|||
|
|
import tailwindcss from '@tailwindcss/vite'
|
|||
|
|
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
|||
|
|
|
|||
|
|
const pathSrc = resolve(__dirname, 'src')
|
|||
|
|
|
|||
|
|
// https://vite.dev/config/
|
|||
|
|
export default defineConfig({
|
|||
|
|
plugins: [
|
|||
|
|
vue(),
|
|||
|
|
tailwindcss(),
|
|||
|
|
vueDevTools(),
|
|||
|
|
AutoImport({
|
|||
|
|
imports: ['vue'],
|
|||
|
|
resolvers: [ElementPlusResolver()],
|
|||
|
|
eslintrc: {
|
|||
|
|
enabled: false,
|
|||
|
|
// 1、改为true用于生成eslint配置。2、生成后改回false,避免重复生成消耗
|
|||
|
|
},
|
|||
|
|
}),
|
|||
|
|
Components({
|
|||
|
|
resolvers: [ElementPlusResolver()],
|
|||
|
|
}),
|
|||
|
|
createSvgIconsPlugin({
|
|||
|
|
// 指定需要缓存的图标文件夹
|
|||
|
|
iconDirs: [resolve(pathSrc, 'assets/icons')],
|
|||
|
|
// 指定symbolId格式
|
|||
|
|
symbolId: 'icon-[dir]-[name]',
|
|||
|
|
}),
|
|||
|
|
],
|
|||
|
|
resolve: {
|
|||
|
|
alias: {
|
|||
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
server: {
|
|||
|
|
proxy: {
|
|||
|
|
'/api': {
|
|||
|
|
changeOrigin: true,
|
|||
|
|
// 接口地址
|
|||
|
|
target: 'http://localhost:8000',
|
|||
|
|
rewrite: (path: string) =>
|
|||
|
|
path.replace(/^\/api/, ''),
|
|||
|
|
configure: (proxy, options) => {
|
|||
|
|
console.log('Proxy configured:', options)
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
}
|
|||
|
|
})
|