2024-08-08 19:08:15 +08:00
|
|
|
|
import {defineConfig, loadEnv} from 'vite'
|
|
|
|
|
|
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
2024-08-07 21:48:57 +08:00
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
|
|
import path from 'path'
|
|
|
|
|
|
|
2024-08-21 14:52:36 +08:00
|
|
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
|
|
|
|
import Components from 'unplugin-vue-components/vite'
|
|
|
|
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
2024-08-08 19:08:15 +08:00
|
|
|
|
|
|
|
|
|
|
export default defineConfig((config) => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
plugins: [
|
|
|
|
|
|
vue(),
|
|
|
|
|
|
// svg图标配置,可以使用svg图标
|
|
|
|
|
|
createSvgIconsPlugin({
|
|
|
|
|
|
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
|
|
|
|
|
|
symbolId: 'icon-[dir]-[name]',
|
|
|
|
|
|
}),
|
2024-08-21 14:52:36 +08:00
|
|
|
|
AutoImport({
|
|
|
|
|
|
resolvers: [ElementPlusResolver({
|
|
|
|
|
|
importStyle: "sass",
|
|
|
|
|
|
})]
|
|
|
|
|
|
}),
|
|
|
|
|
|
Components({
|
|
|
|
|
|
resolvers: [ElementPlusResolver({
|
|
|
|
|
|
importStyle: "sass",
|
|
|
|
|
|
})]
|
|
|
|
|
|
}),
|
2024-08-08 19:08:15 +08:00
|
|
|
|
],
|
|
|
|
|
|
// 基础配置
|
|
|
|
|
|
base: './',
|
|
|
|
|
|
publicDir: 'public',
|
|
|
|
|
|
resolve: {
|
|
|
|
|
|
alias: {
|
|
|
|
|
|
'@': path.resolve(__dirname, 'src'),
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
css: {
|
|
|
|
|
|
preprocessorOptions: {
|
|
|
|
|
|
less: {
|
|
|
|
|
|
modifyVars: {
|
|
|
|
|
|
'@border-color-base': '#dce3e8',
|
|
|
|
|
|
},
|
|
|
|
|
|
javascriptEnabled: true,
|
|
|
|
|
|
},
|
2024-08-21 14:52:36 +08:00
|
|
|
|
scss: {
|
|
|
|
|
|
// 引入index.scss覆盖文件
|
|
|
|
|
|
additionalData: `@use "@/theme/index.scss" as *;`,
|
|
|
|
|
|
}
|
2024-08-08 19:08:15 +08:00
|
|
|
|
},
|
2024-08-07 21:48:57 +08:00
|
|
|
|
},
|
2024-08-08 19:08:15 +08:00
|
|
|
|
build: {
|
|
|
|
|
|
outDir: 'dist',
|
|
|
|
|
|
assetsDir: 'assets',
|
|
|
|
|
|
assetsInlineLimit: 4096,
|
|
|
|
|
|
cssCodeSplit: true,
|
|
|
|
|
|
sourcemap: false,
|
|
|
|
|
|
minify: 'terser',
|
|
|
|
|
|
terserOptions: {
|
|
|
|
|
|
compress: {
|
|
|
|
|
|
// 生产环境去除console及debug
|
|
|
|
|
|
drop_console: false,
|
|
|
|
|
|
drop_debugger: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2024-08-19 14:01:14 +08:00
|
|
|
|
server: {
|
|
|
|
|
|
host: '0.0.0.0',
|
|
|
|
|
|
open: false,
|
|
|
|
|
|
proxy: {
|
|
|
|
|
|
'/api': {
|
|
|
|
|
|
target: 'http://192.168.1.125:18092', //hsw
|
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
|
rewrite: path => path.replace(/^\/api/, '') //路径重写,把'/api'替换为''
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2024-08-08 19:08:15 +08:00
|
|
|
|
}
|
2024-08-07 21:48:57 +08:00
|
|
|
|
})
|