vite.config.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import vue from '@vitejs/plugin-vue'
  2. // import {vitePluginSvg} from "@webxrd/vite-plugin-svg"
  3. import { resolve } from 'path'
  4. const pathResolve = (dir) => {
  5. return resolve(__dirname, ".", dir)
  6. }
  7. const alias = {
  8. '@': pathResolve("src")
  9. }
  10. /**
  11. * @description-en vite document address
  12. * @description-cn vite官网
  13. * https://vitejs.cn/config/ */
  14. export default ({ command }) => {
  15. const prodMock = true;
  16. return {
  17. base: './',
  18. resolve: {
  19. alias
  20. },
  21. server: {
  22. port: 3003,
  23. host: '0.0.0.0',
  24. open: true,
  25. proxy: { // 代理配置
  26. // '/dev': 'https://www.fastmock.site/mock/48cab8545e64d93ff9ba66a87ad04f6b/'
  27. },
  28. },
  29. build: {
  30. rollupOptions: {
  31. output: {
  32. manualChunks: {
  33. 'echarts': ['echarts']
  34. }
  35. }
  36. }
  37. },
  38. plugins: [
  39. vue(),
  40. /* vitePluginSvg({
  41. // 必要的。必须是绝对路径组成的数组。
  42. iconDirs: [
  43. resolve(__dirname, 'src/assets/svg'),
  44. ],
  45. // 必要的。入口script
  46. main: resolve(__dirname, 'src/main.js'),
  47. symbolIdFormat: 'icon-[name]'
  48. }), */
  49. ],
  50. css: {
  51. postcss: {
  52. plugins: [
  53. {
  54. postcssPlugin: 'internal:charset-removal',
  55. AtRule: {
  56. charset: (atRule) => {
  57. if (atRule.name === 'charset') {
  58. atRule.remove();
  59. }
  60. }
  61. }
  62. }
  63. ],
  64. },
  65. }
  66. };
  67. }