import { fileURLToPath } from 'url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import path from 'path' import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' // https://vitejs.dev/config/ export default defineConfig({ base: '/lan/', server: { host: '0.0.0.0', proxy: { '/lan-api': { target: 'http://127.0.0.1:8082', changeOrigin: true, rewrite: (p) => p.replace(/^\/lan-api/, '') } } }, plugins: [ vue(), AutoImport({ imports: [ 'vue', 'vue-router' ], resolvers: [ElementPlusResolver()], }), Components({ directoryAsNamespace: true, resolvers: [ElementPlusResolver({ importStyle: "sass" })], }), createSvgIconsPlugin({ // 配置路劲在你的src里的svg存放文件 iconDirs: [fileURLToPath(new URL('./src/assets/icons', import.meta.url))], symbolId: 'local-icon-[name]' }), ], resolve: { // https://cn.vitejs.dev/config/#resolve-alias alias: { // 设置别名 '~/': `${path.resolve(__dirname, 'src')}/`, '@': path.resolve(__dirname, './src/') }, // https://cn.vitejs.dev/config/#resolve-extensions extensions: ['.js', '.ts'] }, css: { preprocessorOptions: { scss: { additionalData: `@use "src/style/theme.scss" as *;` }, }, } })