|
|
|
|
/*
|
|
|
|
|
* @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'
|
|
|
|
|
// const VITE_APP_SERVER_URL: string = loadEnv(mode, process.cwd()).VITE_APP_SERVER_URL;
|
|
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
server: {
|
|
|
|
|
open: true,
|
|
|
|
|
cors: true,
|
|
|
|
|
host: '0.0.0.0',
|
|
|
|
|
proxy: {
|
|
|
|
|
"^/api": { //服务器接口路径地址,根据路径设置
|
|
|
|
|
target: 'http://39.100.77.21:8000', //你的服务器地址
|
|
|
|
|
changeOrigin: true, // 允许跨域
|
|
|
|
|
ws: true,
|
|
|
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'~/': `${path.resolve(__dirname, 'src')}/`,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
uni(),
|
|
|
|
|
Components({
|
|
|
|
|
resolvers: [VantResolver()],
|
|
|
|
|
}),
|
|
|
|
|
createSvgIconsPlugin({
|
|
|
|
|
//指定图标文件夹,绝对路径(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,
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
})
|