代码拉取完成,页面将自动刷新
import { fileURLToPath, URL } from 'node:url'
import path from 'path'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())
const { VITE_BASE_PATH } = env
return {
base: VITE_BASE_PATH,
plugins: [
vue(),
vueJsx(),
createSvgIconsPlugin({
// 指定要缓存的文件夹
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons/svg')],
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]',
}),
nodePolyfills({
// Whether to polyfill `node:` protocol imports.
protocolImports: true,
}),
],
server: {
// 本地服务器主机名 配置后可以使用本地网络访问
host: true,
// 指定启动端口号
port: 3002,
// 设为 true 时若端口已被占用则会直接退出,而不是尝试下一个可用端口
strictPort: false,
// 服务器启动时自动在浏览器中打开应用程序,当此值为字符串时,会被用作 URL 的路径名
open: true,
proxy: {
'/api': {
target: 'https://dev-api.gpumall.com/api/',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
'/docs': {
target: 'https://gpumall.com.cn/docs/',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/docs/, ''),
}
},
},
resolve: {
// 别名
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'comps': fileURLToPath(new URL('src/components', import.meta.url)),
'views': fileURLToPath(new URL('src/views', import.meta.url)),
'stores': fileURLToPath(new URL('src/stores', import.meta.url)),
'utils': fileURLToPath(new URL('src/utils', import.meta.url)),
'libs': fileURLToPath(new URL('src/libs', import.meta.url)),
'api': fileURLToPath(new URL('src/api', import.meta.url)),
'styles': fileURLToPath(new URL('src/styles', import.meta.url))
}
},
css: {
preprocessorOptions: {
scss: {
additionalData: '@import \'@/assets/styles/abstracts/_variables.scss\';'
},
less: {
modifyVars: {
// 在这里添加你想要修改的 Ant Design Vue 主题变量
// 例如,修改主色为蓝色
'@primary-color': "#0077FF",
'@success-color': '#80b178',
'@warning-color': '#d8c49a',
'@error-color': '#d1786b',
'@heading-color': '#333333',
'@text-color': '#666666',
'@text-color-secondary': '#999999'
},
javascriptEnabled: true
}
}
}
}
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。