vite.config.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { UserConfig, ConfigEnv, loadEnv, defineConfig } from 'vite';
  2. import createPlugins from './vite/plugins';
  3. import path from 'path';
  4. export default defineConfig(({ mode, command }: ConfigEnv): UserConfig => {
  5. const env = loadEnv(mode, process.cwd());
  6. return {
  7. // 部署生产环境和开发环境下的URL。
  8. // 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上
  9. // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
  10. base: env.VITE_APP_CONTEXT_PATH,
  11. resolve: {
  12. alias: {
  13. '~': path.resolve(__dirname, './'),
  14. '@': path.resolve(__dirname, './src')
  15. },
  16. extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
  17. },
  18. // https://cn.vitejs.dev/config/#resolve-extensions
  19. plugins: createPlugins(env, command === 'build'),
  20. server: {
  21. host: '0.0.0.0',
  22. port: Number(env.VITE_APP_PORT),
  23. open: true,
  24. proxy: {
  25. [env.VITE_APP_BASE_API]: {
  26. target: 'http://jdyw.xt.wenhq.top:8083/',
  27. // target: 'http://localhost:8080/',
  28. changeOrigin: true,
  29. ws: true,
  30. rewrite: (path) => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '')
  31. }
  32. }
  33. },
  34. css: {
  35. preprocessorOptions: {
  36. scss: {
  37. javascriptEnabled: true
  38. }
  39. },
  40. postcss: {
  41. plugins: [
  42. {
  43. postcssPlugin: 'internal:charset-removal',
  44. AtRule: {
  45. charset: (atRule) => {
  46. if (atRule.name === 'charset') {
  47. atRule.remove();
  48. }
  49. }
  50. }
  51. }
  52. ]
  53. }
  54. },
  55. // 预编译
  56. optimizeDeps: {
  57. include: [
  58. 'vue',
  59. 'vue-router',
  60. 'pinia',
  61. 'axios',
  62. '@vueuse/core',
  63. 'echarts',
  64. 'vue-i18n',
  65. '@vueup/vue-quill',
  66. 'bpmn-js/lib/Viewer',
  67. 'bpmn-js/lib/Modeler.js',
  68. 'bpmn-js-properties-panel',
  69. 'min-dash',
  70. 'diagram-js/lib/navigation/movecanvas',
  71. 'diagram-js/lib/navigation/zoomscroll',
  72. 'bpmn-js/lib/features/palette/PaletteProvider',
  73. 'bpmn-js/lib/features/context-pad/ContextPadProvider',
  74. 'diagram-js/lib/draw/BaseRenderer',
  75. 'tiny-svg',
  76. 'image-conversion',
  77. 'element-plus/es/components/**/css'
  78. ]
  79. }
  80. };
  81. });