You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.3 KiB

1 year ago
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import path from 'path'
  4. import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
  5. const baseUrl = {
  6. development: './',
  7. beta: './',
  8. release: './'
  9. }
  10. // https://vitejs.dev/config/
  11. export default ({ mode }) => defineConfig({
  12. plugins: [
  13. vue(),
  14. createSvgIconsPlugin({
  15. // 指定需要缓存的图标文件夹
  16. iconDirs: [path.resolve(process.cwd(), 'src/assets/img/icons')],
  17. // 指定symbolId格式
  18. symbolId: 'icon-[name]',
  19. }),
  20. ],
  21. base: baseUrl[mode],
  22. build: {
  23. minify: 'terser',
  24. terserOptions: {
  25. compress: {
  26. // 生产环境打包移除console
  27. drop_console: true,
  28. drop_debugger: true,
  29. }
  30. }
  31. },
  32. resolve: {
  33. alias: {
  34. '~': path.resolve(__dirname, './'),
  35. '@': path.resolve(__dirname, 'src'),
  36. '@assets': path.resolve(__dirname, 'src/assets'),
  37. }
  38. },
  39. css: {
  40. preprocessorOptions: {
  41. less: {
  42. additionalData: '@import "./src/assets/style/global.less";'
  43. }
  44. }
  45. },
  46. server: {
  47. port: 8089,
  48. proxy: {
  49. '/api': {
  50. target: 'http://192.168.99.111:5001',
  51. changeOrigin: true,
  52. rewrite: path => path.replace(/^\/api/, '')
  53. }
  54. }
  55. }
  56. })