vite.config.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { defineConfig } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import vueJsx from "@vitejs/plugin-vue-jsx";
  4. import legacy from "@vitejs/plugin-legacy";
  5. import { resolve } from "path";
  6. import postCssPxToRem from "postcss-pxtorem";
  7. import { createStyleImportPlugin } from "vite-plugin-style-import";
  8. import components from "unplugin-vue-components/vite";
  9. import autoImport from "unplugin-auto-import/vite";
  10. import { VarletUIResolver, NaiveUiResolver } from "unplugin-vue-components/resolvers";
  11. // https://vitejs.dev/config/
  12. export default defineConfig({
  13. base: "./",
  14. resolve: {},
  15. plugins: [
  16. // mkcert(), // 本地https
  17. legacy({
  18. targets: "last 2 versions and not dead, > 0.3%, Firefox ESR",
  19. }),
  20. vue(),
  21. vueJsx(),
  22. // components({
  23. // resolvers: [NaiveUiResolver()],
  24. // })
  25. ],
  26. css: {
  27. postcss: {
  28. plugins: [
  29. // postCssPxToRem({
  30. // rootValue: 37.5,
  31. // propList: ["*"],
  32. // selectorBlackList: [".norem"],
  33. // }),
  34. ],
  35. },
  36. },
  37. build: {
  38. rollupOptions: {
  39. input: {
  40. index: resolve(__dirname, "index.html"),
  41. },
  42. },
  43. },
  44. server: {
  45. cors: true,
  46. port: 3050,
  47. // https: true,
  48. proxy: {
  49. "^/edu-app/.*": {
  50. target: "https://test.lexiaoya.cn",
  51. changeOrigin: true,
  52. // rewrite: (path) => path.replace(/^\/edu-app/, ""),
  53. },
  54. },
  55. },
  56. });
  57. // vite.config.js