vite.config.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { loadEnv } from 'vite';
  2. import { viteMockServe } from 'vite-plugin-mock';
  3. import { createVuePlugin } from 'vite-plugin-vue2';
  4. import { createSvgPlugin } from 'vite-plugin-vue2-svg';
  5. import path from 'path';
  6. const CWD = process.cwd();
  7. export default ({ mode }) => {
  8. const { VITE_BASE_URL } = loadEnv(mode, CWD);
  9. return {
  10. base: VITE_BASE_URL,
  11. resolve: {
  12. alias: {
  13. '~': path.resolve(__dirname, './'),
  14. '@': path.resolve(__dirname, './src'),
  15. },
  16. },
  17. css: {
  18. preprocessorOptions: {
  19. less: {
  20. modifyVars: {},
  21. },
  22. },
  23. },
  24. plugins: [
  25. createVuePlugin({
  26. jsx: true,
  27. }),
  28. viteMockServe({
  29. mockPath: 'mock',
  30. localEnabled: true,
  31. }),
  32. createSvgPlugin(),
  33. ],
  34. build: {
  35. outDir: "plane",
  36. cssCodeSplit: false,
  37. },
  38. server: {
  39. host: '0.0.0.0',
  40. port: 3001,
  41. proxy: {
  42. '/api': {
  43. // 用于开发环境下的转发请求
  44. // 更多请参考:https://vitejs.dev/config/#server-proxy
  45. target: 'https://service-exndqyuk-1257786608.gz.apigw.tencentcs.com',
  46. changeOrigin: true,
  47. },
  48. },
  49. },
  50. };
  51. };