142 lines
3.2 KiB
JavaScript
142 lines
3.2 KiB
JavaScript
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import { defineConfig } from 'vite'
|
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
vueDevTools(),
|
|
tailwindcss(),
|
|
AutoImport({
|
|
// 自动引入 Vue 相关函数
|
|
imports: [
|
|
'vue',
|
|
'vue-router',
|
|
'pinia',
|
|
'@vueuse/core',
|
|
{
|
|
'axios': [
|
|
['default', 'axios']
|
|
],
|
|
'dayjs': [
|
|
['default', 'dayjs']
|
|
],
|
|
'lodash-es': [
|
|
'isEmpty',
|
|
'isEqual',
|
|
'get',
|
|
'set',
|
|
'omit',
|
|
'pick',
|
|
'merge',
|
|
'uniq',
|
|
'uniqBy',
|
|
'groupBy',
|
|
'keyBy',
|
|
'sortBy',
|
|
'orderBy',
|
|
'filter',
|
|
'map',
|
|
'reduce',
|
|
'find',
|
|
'findIndex',
|
|
'includes',
|
|
'startsWith',
|
|
'endsWith',
|
|
'camelCase',
|
|
'kebabCase',
|
|
'snakeCase',
|
|
'capitalize',
|
|
'upperCase',
|
|
'lowerCase',
|
|
'trim',
|
|
'escape',
|
|
'unescape'
|
|
],
|
|
}
|
|
],
|
|
resolvers: [
|
|
ElementPlusResolver(),
|
|
],
|
|
// 自动引入 Vue 模板中的组件
|
|
dts: true,
|
|
// 自动引入目录下的模块
|
|
dirs: [
|
|
'./src/composables/**',
|
|
'./src/stores/**',
|
|
'./src/utils/**'
|
|
],
|
|
// 自动引入 Vue 相关函数
|
|
vueTemplate: true,
|
|
// 自动引入类型
|
|
eslintrc: {
|
|
enabled: true,
|
|
filepath: './.eslintrc-auto-import.json',
|
|
globalsPropValue: true,
|
|
},
|
|
}),
|
|
Components({
|
|
// 自动引入组件
|
|
resolvers: [
|
|
ElementPlusResolver({
|
|
importStyle: 'sass',
|
|
}),
|
|
],
|
|
// 自动引入目录下的组件
|
|
dirs: ['src/components'],
|
|
// 组件的有效文件扩展名
|
|
extensions: ['vue'],
|
|
// 配置文件生成位置
|
|
dts: true,
|
|
// 自动引入指令
|
|
directives: true,
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
},
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
importers: [
|
|
// ...
|
|
],
|
|
},
|
|
},
|
|
},
|
|
build: {
|
|
sourcemap: true,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: undefined
|
|
}
|
|
}
|
|
},
|
|
server: {
|
|
proxy: {
|
|
// // 本地开发时将 /api/v1 的请求代理到 8080 端口
|
|
'/api/v1': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
// 保持路径不变
|
|
rewrite: path => path,
|
|
},
|
|
// '/api/v1': {
|
|
// target: 'https://console.tianyuanapi.com',
|
|
// changeOrigin: true,
|
|
// // 保持路径不变
|
|
// rewrite: path => path,
|
|
// },
|
|
},
|
|
},
|
|
})
|