vite.config.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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: 8000,
  23. // strictPort: true,
  24. https: false,
  25. force: true,
  26. proxy: {
  27. '/api': {
  28. target: 'http://sqpcbg.xt.wenhq.top:8083',
  29. changeOrigin: true,
  30. // rewrite: (path) => path.replace(/^\/api/, ''),
  31. },
  32. },
  33. },
  34. resolve: {
  35. alias: {
  36. '@': path.resolve(__dirname, './src'),
  37. '@assets': path.resolve(__dirname, './src/assets'),
  38. },
  39. },
  40. css: {
  41. modules: {
  42. localsConvention: 'camelCase', // 默认只支持驼峰,修改为同事支持横线和驼峰
  43. },
  44. preprocessorOptions: {
  45. scss: {
  46. /**
  47. * TODO:// 目前按需加载时修改主题色会报错
  48. * 官方修复后在进行按需加载
  49. * @link {https://github.com/element-plus/element-plus/issues/2724}
  50. *
  51. * */
  52. // additionalData: `@use "@/styles/element/index.scss" as *;`,
  53. },
  54. // scss: { additionalData: `@import "@/styles/vars.scss";` },
  55. // less: {
  56. // javascriptEnabled: true,
  57. // additionalData: `@import "@/styles/default.less";`,
  58. // },
  59. },
  60. },
  61. plugins: [
  62. vue(),
  63. vueJsx({
  64. // options are passed on to @vue/babel-plugin-jsx
  65. }),
  66. imageLoader(),
  67. // svgLoader(),
  68. // ElementPlus({ useSource: true }),
  69. ],
  70. };
  71. };