大语言模型
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * @Author: wrh
  3. * @Date: 2025-04-07 12:47:46
  4. * @LastEditors: wrh
  5. * @LastEditTime: 2025-04-08 09:02:00
  6. */
  7. import { defineConfig, loadEnv } from 'vite'
  8. import path from 'path'
  9. import createVitePlugins from './vite/plugins'
  10. // https://vitejs.dev/config/
  11. export default defineConfig(({ mode, command }) => {
  12. const env = loadEnv(mode, process.cwd())
  13. const { VITE_APP_ENV } = env
  14. return {
  15. // 部署生产环境和开发环境下的URL。
  16. // 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上
  17. // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
  18. base: VITE_APP_ENV === 'production' ? '/' : '/',
  19. plugins: createVitePlugins(env, command === 'build'),
  20. resolve: {
  21. // https://cn.vitejs.dev/config/#resolve-alias
  22. alias: {
  23. // 设置路径
  24. '~': path.resolve(__dirname, './'),
  25. // 设置别名
  26. '@': path.resolve(__dirname, './src')
  27. },
  28. // https://cn.vitejs.dev/config/#resolve-extensions
  29. extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
  30. },
  31. // vite 相关配置
  32. server: {
  33. port: 81,
  34. host: true,
  35. open: true,
  36. proxy: {
  37. // https://cn.vitejs.dev/config/#server-proxy
  38. '/dev-api': {
  39. target: 'http://localhost:8080',
  40. changeOrigin: true,
  41. rewrite: (p) => p.replace(/^\/dev-api/, '')
  42. }
  43. }
  44. },
  45. //fix:error:stdin>:7356:1: warning: "@charset" must be the first rule in the file
  46. css: {
  47. postcss: {
  48. plugins: [
  49. {
  50. postcssPlugin: 'internal:charset-removal',
  51. AtRule: {
  52. charset: (atRule) => {
  53. if (atRule.name === 'charset') {
  54. atRule.remove();
  55. }
  56. }
  57. }
  58. }
  59. ]
  60. }
  61. }
  62. }
  63. })