58 lines
1.4 KiB
JavaScript
58 lines
1.4 KiB
JavaScript
import { fileURLToPath, URL } from 'node:url'
|
||
|
||
import { defineConfig } from 'vite'
|
||
import vue from '@vitejs/plugin-vue'
|
||
|
||
// element-plus按需要导入
|
||
import AutoImport from 'unplugin-auto-import/vite'
|
||
import Components from 'unplugin-vue-components/vite'
|
||
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
||
|
||
// https://vitejs.dev/config/
|
||
export default defineConfig({
|
||
build: {
|
||
outDir: 'website-www',
|
||
chunkSizeWarningLimit: 1600
|
||
},
|
||
base: '/website-www/',
|
||
plugins: [
|
||
vue(),
|
||
AutoImport({
|
||
//自动引入vue的ref、toRefs、onmounted等,无需在页面中再次引入
|
||
imports: ['vue', 'vue-router'],
|
||
resolvers: [ElementPlusResolver()]
|
||
}),
|
||
Components({
|
||
// 配置element-plus采用sass样式配置系统
|
||
resolvers: [ElementPlusResolver({ importStyle: 'sass' })]
|
||
})
|
||
],
|
||
resolve: {
|
||
// 实际路径转换 @ -> src
|
||
alias: {
|
||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||
}
|
||
},
|
||
server: {
|
||
proxy: {
|
||
// 代理配置
|
||
'/ws-api': {
|
||
target: 'http://localhost:9090',
|
||
changeOrigin: true,
|
||
rewrite: (p) => p.replace(/^\/ws-api/, '')
|
||
}
|
||
}
|
||
},
|
||
css: {
|
||
preprocessorOptions: {
|
||
scss: {
|
||
// 自动导入定制化样式文件进行样式覆盖
|
||
additionalData: `
|
||
@use "@/styles/element/index.scss" as *;
|
||
@use "@/styles/var.scss" as *;
|
||
`
|
||
}
|
||
}
|
||
}
|
||
})
|