Test/vite.config.js
wuhuanxiao 8054a60a86 test
2025-01-08 15:30:48 +08:00

80 lines
2.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @Company: 沈阳信诚科技
* @Email: html_venustar@163.com
* @Author: Liuqiming
* @Description: 项目基础配置
* @LastEditors: Liuqiming
* @LastEditTime: 2024-03-01 09:37:52
* @Date: 2024-02-01 16:33:25
*/
import { defineConfig, loadEnv } from 'vite'
import path from 'path'
import createVitePlugins from './vite/plugins'
// https://vitejs.dev/config/
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd())
return {
// 部署生产环境和开发环境下的URL。
// 默认情况下vite 会假设你的应用是被部署在一个域名的根路径上
// 例如,如果你的应用被部署在 https://www.***.vip/admin/,则设置 baseUrl 为 /admin/。
base: env.VITE_APP_CONTEXT_PATH,
plugins: createVitePlugins(env, command === 'build'),
resolve: {
// https://cn.vitejs.dev/config/#resolve-alias
alias: {
// 设置路径
'~': path.resolve(__dirname, './'),
// 设置别名
'@': path.resolve(__dirname, './src'),
// 设置便捷路径
'@A': path.resolve(__dirname, './src/api'),
'@S': path.resolve(__dirname, './src/assets'),
'@C': path.resolve(__dirname, './src/components'),
'@U': path.resolve(__dirname, './src/utils')
},
// https://cn.vitejs.dev/config/#resolve-extensions
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
// vite 相关配置
server: {
port: 8088,
host: true,
open: true,
proxy: {
// https://cn.vitejs.dev/config/#server-proxy
'/dev-api': {
target: 'http://localhost:8080',
// target: 'http://192.168.3.32:8080', // 刘壮后台
// target: 'http://192.168.1.61:8481', // 沈阳服务器
// target: 'http://192.168.3.146:8080', // 马成龙后台
changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-api/, '')
}
}
},
//fix:error:stdin>:7356:1: warning: "@charset" must be the first rule in the file
css: {
postcss: {
plugins: [
{
postcssPlugin: 'internal:charset-removal',
AtRule: {
charset: (atRule) => {
if (atRule.name === 'charset') {
atRule.remove();
}
}
}
}
]
},
preprocessorOptions: {
scss: {
additionalData: `@import "@/assets/styles/wh.scss";`
}
}
}
}
})