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

77 lines
2.7 KiB
TypeScript

1 year ago
/*
* @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
* @Date: 2023-07-28 16:10:52
* @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
* @LastEditTime: 2023-08-08 18:20:30
* @FilePath: \byhl-zt-app\vite.config.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import path from 'path'
import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import Unocss from 'unocss/vite'
import transformWeClass from 'unplugin-transform-we-class/vite'
import AutoImport from 'unplugin-auto-import/vite'
import vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
1 year ago
// const VITE_APP_SERVER_URL: string = loadEnv(mode, process.cwd()).VITE_APP_SERVER_URL;
// https://vitejs.dev/config/
export default defineConfig({
1 year ago
server: {
open: true,
cors: true,
10 months ago
host: '0.0.0.0',
1 year ago
proxy: {
"^/api": { //服务器接口路径地址,根据路径设置
10 months ago
target: 'http://39.100.77.21:8000', //你的服务器地址
1 year ago
changeOrigin: true, // 允许跨域
10 months ago
ws: true,
1 year ago
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
resolve: {
alias: {
'~/': `${path.resolve(__dirname, 'src')}/`,
},
},
plugins: [
uni(),
Components({
resolvers: [VantResolver()],
}),
createSvgIconsPlugin({
1 year ago
//指定图标文件夹,绝对路径(NODE代码)
iconDirs: [path.resolve(process.cwd(), 'src/icons')],
symbolId: 'icon-[name]',
}),
// https://github.com/antfu/unocss
// Unocss(),
// app打包配置
// uniapp打包app时打包2次一次使用 vue 模式打包h5第2次使用 nvue 模式打包app
// 第2次打包 unocss 会抛出warn
// entry module not found, have you add `import 'uno.css'` in your main entry?
// 导致打包终止
process.env.UNI_COMPILER !== 'nvue' ? Unocss() : undefined,
// https://github.com/MellowCo/unplugin-transform-we-class
transformWeClass(),
// https://github.com/antfu/unplugin-auto-import
AutoImport({
imports: [
'vue',
'uni-app',
'pinia',
],
dts: true,
vueTemplate: true,
}),
],
})