vite.config.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import path from 'path';
  2. import { UserConfigExport, ConfigEnv } from 'vite';
  3. import vueJsx from '@vitejs/plugin-vue-jsx';
  4. import vue from '@vitejs/plugin-vue';
  5. import svgLoader from 'vite-svg-loader';
  6. import imageLoader from '@rollup/plugin-image';
  7. import Components from 'unplugin-vue-components/vite';
  8. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
  9. import ElementPlus from 'unplugin-element-plus/vite';
  10. /**
  11. * @type {import('vite').UserConfig}
  12. * @link {https://vitejs.cn/config/}
  13. */
  14. export default ({ command, mode }: ConfigEnv): UserConfigExport => {
  15. console.log(command);
  16. return {
  17. root: process.cwd(),
  18. base: './',
  19. server: {
  20. host: '0.0.0.0',
  21. open: true,
  22. port: 8001,
  23. // strictPort: true,
  24. https: false,
  25. force: true,
  26. proxy: {
  27. '/api': {
  28. target: 'http://61.147.254.211:30876/YJZH-SQ/',
  29. // target: 'http://sqpcbg.xt.wenhq.top:8083/',
  30. changeOrigin: true,
  31. // rewrite: (path) => path.replace(/^\/api/, ''),
  32. },
  33. },
  34. },
  35. resolve: {
  36. alias: {
  37. '@': path.resolve(__dirname, './src'),
  38. '@assets': path.resolve(__dirname, './src/assets'),
  39. },
  40. },
  41. css: {
  42. modules: {
  43. localsConvention: 'camelCase', // 默认只支持驼峰,修改为同事支持横线和驼峰
  44. },
  45. preprocessorOptions: {
  46. scss: {
  47. /**
  48. * TODO:// 目前按需加载时修改主题色会报错
  49. * 官方修复后在进行按需加载
  50. * @link {https://github.com/element-plus/element-plus/issues/2724}
  51. *
  52. * */
  53. // additionalData: `@use "@/styles/element/index.scss" as *;`,
  54. },
  55. // scss: { additionalData: `@import "@/styles/vars.scss";` },
  56. // less: {
  57. // javascriptEnabled: true,
  58. // additionalData: `@import "@/styles/default.less";`,
  59. // },
  60. },
  61. },
  62. plugins: [
  63. vue(),
  64. vueJsx({
  65. // options are passed on to @vue/babel-plugin-jsx
  66. }),
  67. imageLoader(),
  68. // svgLoader(),
  69. // ElementPlus({ useSource: true }),
  70. ],
  71. };
  72. };