vite.config.js 2.1 KB

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