plugins.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { cdn } from "./cdn";
  2. import vue from "@vitejs/plugin-vue";
  3. import { viteBuildInfo } from "./info";
  4. import svgLoader from "vite-svg-loader";
  5. import vueJsx from "@vitejs/plugin-vue-jsx";
  6. import { configCompressPlugin } from "./compress";
  7. // import ElementPlus from "unplugin-element-plus/vite";
  8. import { visualizer } from "rollup-plugin-visualizer";
  9. import removeConsole from "vite-plugin-remove-console";
  10. import Components from "unplugin-vue-components/vite";
  11. import { VantResolver } from "@vant/auto-import-resolver";
  12. export function getPluginsList(
  13. command: string,
  14. VITE_CDN: boolean,
  15. VITE_COMPRESSION: ViteCompression
  16. ) {
  17. const prodMock = true;
  18. const lifecycle = process.env.npm_lifecycle_event;
  19. return [
  20. vue(),
  21. // jsx、tsx语法支持
  22. vueJsx(),
  23. Components({
  24. resolvers: [VantResolver()],
  25. }),
  26. VITE_CDN ? cdn : null,
  27. configCompressPlugin(VITE_COMPRESSION),
  28. // 线上环境删除console
  29. // removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }),
  30. viteBuildInfo(),
  31. // svg组件化支持
  32. svgLoader(),
  33. // ElementPlus({}),
  34. // 打包分析
  35. lifecycle === "report"
  36. ? visualizer({ open: true, brotliSize: true, filename: "report.html" })
  37. : null,
  38. ];
  39. }