书院官网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vite.config.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { defineConfig, loadEnv } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import { resolve } from "path";
  4. import AutoImport from "unplugin-auto-import/vite";
  5. import Components from "unplugin-vue-components/vite";
  6. // 按需引入 ElementPlus vant
  7. import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
  8. import { VantResolver } from "unplugin-vue-components/resolvers";
  9. // 生成.gz文件
  10. import viteCompression from "vite-plugin-compression";
  11. // https://vitejs.dev/config/
  12. export default defineConfig(({ mode }) => {
  13. let env = loadEnv(mode, process.cwd());
  14. return {
  15. plugins: [
  16. vue(),
  17. AutoImport({
  18. // 自动导入vue相关的Api
  19. imports: ["vue", "vue-router"],
  20. resolvers: [ElementPlusResolver()],
  21. }),
  22. Components({
  23. resolvers: [ElementPlusResolver(), VantResolver()],
  24. }),
  25. {
  26. ...viteCompression(),
  27. apply: "build",
  28. },
  29. ],
  30. resolve: {
  31. // 配置路径别名
  32. alias: {
  33. "@": resolve(__dirname, "./src"),
  34. },
  35. },
  36. css: {
  37. // CSS 预处理器
  38. preprocessorOptions: {
  39. //define global scss variable
  40. scss: {
  41. javascriptEnabled: true,
  42. additionalData: `@import "@/styles/variables.scss";`,
  43. },
  44. },
  45. },
  46. server: {
  47. host: "0.0.0.0",
  48. port: 8081,
  49. open: true,
  50. https: false,
  51. proxy: {
  52. "/api": {
  53. target: env.VITE_BASE_URL,
  54. changeOrigin: true,
  55. ws: true,
  56. rewrite: path => path.replace(/^\/api/, ""),
  57. },
  58. },
  59. },
  60. build: {
  61. rollupOptions: {
  62. output: {
  63. manualChunks: {
  64. vue: ["vue", "pinia", "vue-router"],
  65. elementIcons: ["@element-plus/icons-vue"],
  66. },
  67. chunkFileNames: "wap/js/[name]-[hash].js",
  68. entryFileNames: "wap/js/[name]-[hash].js",
  69. assetFileNames: "wap/[ext]/[name]-[hash].[ext]",
  70. },
  71. },
  72. },
  73. };
  74. });