You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
customAgent/vite.config.js

90 lines
2.4 KiB

import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// import { vitePluginFakeServer } from 'vite-plugin-fake-server'
import vueDevTools from 'vite-plugin-vue-devtools'
// https://vite.dev/config/
export default defineConfig(({ command }) => {
// 是否是开发环境
const isDev = command === 'serve'
return {
base: "/yykf/",
server: {
proxy: {
'/yykf/liics_api': {
target: 'https://aioblu-sit.cpic.com.cn',
changeOrigin: true,
ws: true,
},
},
},
plugins: [
vue(),
// 暂时禁用 fake server,使用真实后端服务
// ...(isDev
// ? [
// vitePluginFakeServer({
// enableDev: true,
// logger: false,
// include: 'mock',
// enableProd: false,
// }),
// ]
// : []),
vueDevTools(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
},
esbuild: {
// 仅在构建阶段移除 console/debugger,开发调试保留
// drop: isDev ? [] : ['console', 'debugger']
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "@/assets/style/variable.scss";`
}
}
},
build: {
minify: 'esbuild',
rollupOptions: {
output: {
// JS 文件存放规则
entryFileNames: 'js/[name]-[hash].js',
chunkFileNames: 'js/[name]-[hash].js',
// CSS 文件存放规则
assetFileNames: (assetInfo) => {
// 判断文件类型
const extType = assetInfo.name.split('.').pop().toLowerCase()
// CSS 文件放到 css 文件夹
if (extType === 'css') {
return 'css/[name]-[hash][extname]'
}
// 图片文件放到 images 文件夹
if (['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp', 'ico'].includes(extType)) {
return 'images/[name]-[hash][extname]'
}
// 字体文件放到 fonts 文件夹
if (['woff', 'woff2', 'eot', 'ttf', 'otf'].includes(extType)) {
return 'fonts/[name]-[hash][extname]'
}
// 其他资源文件放到 assets 文件夹
return 'assets/[name]-[hash][extname]'
}
}
}
}
}
})