202 lines
7.3 KiB
TypeScript
202 lines
7.3 KiB
TypeScript
import { defineConfig, loadEnv } from 'vite'
|
||
import vue from '@vitejs/plugin-vue'
|
||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||
import { resolve } from 'path'
|
||
|
||
import themeConfig from './src/themeConfig'
|
||
/*
|
||
unplugin-vue-components(实现组件按需引入)
|
||
原名为vite-plugin-components 后更名为unplugin-vue-components
|
||
*/
|
||
/*
|
||
解决本地css 编译过慢的方法
|
||
注释 48 行 themePreprocessorPlugin(themeConfig)
|
||
打开 66 行 '@primary-color':'#1965FF', // 全局主色
|
||
*/
|
||
import Components from 'unplugin-vue-components/vite'
|
||
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
|
||
|
||
export default ({ mode }) => {
|
||
// 解析env对象
|
||
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }
|
||
|
||
return defineConfig({
|
||
server: {
|
||
host: true, // 监听所有host包括局域网
|
||
port: 8002,
|
||
proxy: {
|
||
'/api': {
|
||
// target: 'http://192.168.1.5:9219/', // 代理的目标地址
|
||
// target: 'https://p.rscygroup.com/', // 代理的目标地址
|
||
target: 'http://agent.sxczgkj.cn/', // 代理的目标地址
|
||
changeOrigin: true, // 开启跨域
|
||
}
|
||
}
|
||
},
|
||
|
||
base: process.env.VITE_APP_BASE_URL,
|
||
|
||
// 定义ENV, 可全局取到
|
||
define: {
|
||
'process.env': process.env
|
||
},
|
||
|
||
// @ --> src目录
|
||
resolve: {
|
||
alias: [
|
||
{ find: '@', replacement: resolve(__dirname, 'src') },
|
||
{
|
||
find: 'UIC',
|
||
replacement: resolve(
|
||
__dirname,
|
||
'src/components/link/JeepayUIComponents'
|
||
)
|
||
} //UI-Components缩写
|
||
]
|
||
},
|
||
|
||
plugins: [
|
||
vue(),
|
||
vueJsx(),
|
||
Components({
|
||
resolvers: [
|
||
AntDesignVueResolver({
|
||
importLess: false // 导入less文件, 默认为false, 若需要自定义主题必须开启此选项
|
||
})
|
||
] // 按需引入 antd 组件, 无需显示引入即可。
|
||
})
|
||
],
|
||
esbuild: {
|
||
jsxFactory: 'h',
|
||
jsxFragment: 'Fragment'
|
||
},
|
||
// 解决:Inline JavaScript is not enabled. Is it set in your options 问题
|
||
css: {
|
||
postcss: {},
|
||
preprocessorOptions: {
|
||
less: {
|
||
additionalData: `@import "@/less/color.less";`,
|
||
modifyVars: {
|
||
'@primary-color': '#1965FF', // 全局主色
|
||
'@primary-glass': '#2691ff26', // 半透明主题色
|
||
'@background-color': '#F2F5F7', //light全局背景色
|
||
'@link-color': '#1890ff', // 链接色
|
||
'@login-align': 'flex-end', //登录页表单对话框的对齐方式,flex-start == left; center == center; flex-end == right
|
||
'@success-color': '#52c41a', // 成功色
|
||
'@warning-color': '#faad14', // 警告色
|
||
'@error-color': '#f5222d', // 错误色
|
||
'@font-size-base': '14px', // 主字号
|
||
'@heading-color': 'rgba(0, 0, 0, 0.85)', // 标题色
|
||
'@text-color': 'rgba(0, 0, 0, 0.65)', // 主文本色
|
||
'@text-color-secondary': 'rgba(0, 0, 0, 0.45)', // 次文本色
|
||
'@disabled-color': 'rgba(0, 0, 0, 0.25)', // 失效色
|
||
'@border-radius-base': '4px', // 组件/浮层圆角
|
||
'@border-color-base': '#d9d9d9', // 边框色
|
||
'@box-shadow-base': '0 2px 8px rgba(0, 0, 0, 0.15)' // 浮层阴影
|
||
},
|
||
// DO NOT REMOVE THIS LINE
|
||
javascriptEnabled: true
|
||
}
|
||
}
|
||
},
|
||
optimizeDeps: {
|
||
// 解决 wondiws环境 依赖变更首次加载慢的问题
|
||
include: [
|
||
'@vue/reactivity',
|
||
'qrcode.vue',
|
||
'reconnectingwebsocket',
|
||
'ant-design-vue/es',
|
||
'v-viewer',
|
||
'@amap/amap-jsapi-loader',
|
||
|
||
'ant-design-vue/es/locale/zh_CN',
|
||
'ant-design-vue/es/config-provider/style',
|
||
'ant-design-vue/es/form/style',
|
||
'ant-design-vue/es/input/style',
|
||
'ant-design-vue/es/dropdown/style',
|
||
'ant-design-vue/es/menu/style',
|
||
'ant-design-vue/es/breadcrumb/style',
|
||
'ant-design-vue/es/badge/style',
|
||
'ant-design-vue/es/avatar/style',
|
||
'ant-design-vue/es/card/style',
|
||
'ant-design-vue/es/tag/style',
|
||
'ant-design-vue/es/spin/style',
|
||
'ant-design-vue/es/button/style',
|
||
'ant-design-vue/es/drawer/style',
|
||
'ant-design-vue/es/table/style',
|
||
'ant-design-vue/es/checkbox/style',
|
||
'ant-design-vue/es/switch/style',
|
||
'ant-design-vue/es/tooltip/style',
|
||
'ant-design-vue/es/row/style',
|
||
'ant-design-vue/es/date-picker/style',
|
||
'ant-design-vue/es/col/style',
|
||
'ant-design-vue/es/select/style',
|
||
'ant-design-vue/es/alert/style',
|
||
'ant-design-vue/es/divider/style',
|
||
'ant-design-vue/es/popover/style',
|
||
'ant-design-vue/es/radio/style',
|
||
'ant-design-vue/es/descriptions/style',
|
||
'ant-design-vue/es/upload/style',
|
||
'ant-design-vue/es/modal/style',
|
||
'ant-design-vue/es/input-number/style',
|
||
'ant-design-vue/es/tree/style',
|
||
'ant-design-vue/es/tabs/style',
|
||
'ant-design-vue/es/steps/style',
|
||
'ant-design-vue/es/list/style',
|
||
'ant-design-vue/es/skeleton/style',
|
||
'ant-design-vue/es/empty/style',
|
||
'ant-design-vue/es/cascader/style',
|
||
'ant-design-vue/es/collapse/style',
|
||
'ant-design-vue/es/affix/style',
|
||
'ant-design-vue/es/space/style',
|
||
'ant-design-vue/es/statistic/style',
|
||
'ant-design-vue/es/image/style',
|
||
|
||
'ant-design-vue/es/config-provider/style/css',
|
||
'ant-design-vue/es/form/style/css',
|
||
'ant-design-vue/es/input/style/css',
|
||
'ant-design-vue/es/dropdown/style/css',
|
||
'ant-design-vue/es/menu/style/css',
|
||
'ant-design-vue/es/breadcrumb/style/css',
|
||
'ant-design-vue/es/badge/style/css',
|
||
'ant-design-vue/es/avatar/style/css',
|
||
'ant-design-vue/es/card/style/css',
|
||
'ant-design-vue/es/tag/style/css',
|
||
'ant-design-vue/es/spin/style/css',
|
||
'ant-design-vue/es/button/style/css',
|
||
'ant-design-vue/es/drawer/style/css',
|
||
'ant-design-vue/es/table/style/css',
|
||
'ant-design-vue/es/checkbox/style/css',
|
||
'ant-design-vue/es/switch/style/css',
|
||
'ant-design-vue/es/tooltip/style/css',
|
||
'ant-design-vue/es/row/style/css',
|
||
'ant-design-vue/es/date-picker/style/css',
|
||
'ant-design-vue/es/col/style/css',
|
||
'ant-design-vue/es/select/style/css',
|
||
'ant-design-vue/es/alert/style/css',
|
||
'ant-design-vue/es/divider/style/css',
|
||
'ant-design-vue/es/popover/style/css',
|
||
'ant-design-vue/es/radio/style/css',
|
||
'ant-design-vue/es/descriptions/style/css',
|
||
'ant-design-vue/es/upload/style/css',
|
||
'ant-design-vue/es/modal/style/css',
|
||
'ant-design-vue/es/input-number/style/css',
|
||
'ant-design-vue/es/tree/style/css',
|
||
'ant-design-vue/es/tabs/style/css',
|
||
'ant-design-vue/es/steps/style/css',
|
||
'ant-design-vue/es/list/style/css',
|
||
'ant-design-vue/es/skeleton/style/css',
|
||
'ant-design-vue/es/empty/style/css',
|
||
'ant-design-vue/es/cascader/style/css',
|
||
'ant-design-vue/es/collapse/style/css',
|
||
'ant-design-vue/es/affix/style/css',
|
||
'ant-design-vue/es/space/style/css',
|
||
'ant-design-vue/es/statistic/style/css',
|
||
'ant-design-vue/es/image/style/css',
|
||
'ant-design-vue/es/time-picker/style/css',
|
||
'ant-design-vue/es/typography/style/css'
|
||
]
|
||
}
|
||
})
|
||
}
|