vite.config.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
  4. import { resolve } from 'path'
  5. function pathResolve(dir) {
  6. return resolve(process.cwd(), '.', dir)
  7. }
  8. export default defineConfig({
  9. resolve: {
  10. alias: [
  11. {
  12. find: '@',
  13. replacement: pathResolve('src')
  14. }
  15. ],
  16. dedupe: ['vue']
  17. },
  18. plugins: [
  19. vue(),
  20. createSvgIconsPlugin({
  21. // 指定需要缓存的图标文件夹
  22. iconDirs: [resolve(process.cwd(), 'src/assets/svg')],
  23. // 指定symbolId格式
  24. symbolId: 'icon-[dir]-[name]',
  25. })
  26. ],
  27. css: {
  28. // css预处理器
  29. preprocessorOptions: {
  30. less: {
  31. charset: false, // 解决中文乱码
  32. modifyVars: {
  33. 'arcoblue-6': '#d1402f',
  34. },
  35. javascriptEnabled: true,
  36. additionalData:
  37. '@import "@/assets/css/theme.less";@import "@/assets/css/global.less";',
  38. },
  39. },
  40. },
  41. build: {
  42. minify: true, // 生产环境不生成sourcemap
  43. target: 'es2015',
  44. // 警报门槛,限制大文件大小
  45. chunkSizeWarningLimit: 5000,
  46. rollupOptions: {
  47. external: [], // 外部化处理那些你不想打包进库的依赖
  48. // 静态资源分类打包
  49. output: {
  50. chunkFileNames: 'static/js/[name]-[hash].js',
  51. entryFileNames: 'static/js/[name]-[hash].js',
  52. assetFileNames: 'static/[ext]/[name]-[hash].[ext]'
  53. },
  54. },
  55. },
  56. server: {
  57. port: 8088,
  58. host: '0.0.0.0',
  59. open: true,
  60. cors: true,
  61. hmr: true,
  62. proxy: {
  63. '/api': {
  64. target: "http://sim.nanodreamtech.com",
  65. // target: "http://127.0.0.1:3001",
  66. changeOrigin: true,
  67. ws: true,
  68. secure: true,
  69. },
  70. }
  71. }
  72. })