影像解译
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

vite.config.js 2.3KB

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