1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import { cdn } from "./cdn";
- import vue from "@vitejs/plugin-vue";
- import { viteBuildInfo } from "./info";
- import svgLoader from "vite-svg-loader";
- import type { PluginOption } from "vite";
- import vueJsx from "@vitejs/plugin-vue-jsx";
- import { configCompressPlugin } from "./compress";
- import removeNoMatch from "vite-plugin-router-warn";
- import { visualizer } from "rollup-plugin-visualizer";
- import removeConsole from "vite-plugin-remove-console";
- import { themePreprocessorPlugin } from "@pureadmin/theme";
- import { genScssMultipleScopeVars } from "../src/layout/theme";
- import { vitePluginFakeServer } from "vite-plugin-fake-server";
- export function getPluginsList(
- VITE_CDN: boolean,
- VITE_COMPRESSION: ViteCompression
- ): PluginOption[] {
- const lifecycle = process.env.npm_lifecycle_event;
- return [
- vue(),
- // jsx、tsx语法支持
- vueJsx(),
- viteBuildInfo(),
- /**
- * 开发环境下移除非必要的vue-router动态路由警告No match found for location with path
- * 非必要具体看 https://github.com/vuejs/router/issues/521 和 https://github.com/vuejs/router/issues/359
- * vite-plugin-router-warn只在开发环境下启用,只处理vue-router文件并且只在服务启动或重启时运行一次,性能消耗可忽略不计
- */
- removeNoMatch(),
- // mock支持
- vitePluginFakeServer({
- logger: false,
- include: "mock",
- infixName: false,
- enableProd: true
- }),
- // 自定义主题
- themePreprocessorPlugin({
- scss: {
- multipleScopeVars: genScssMultipleScopeVars(),
- extract: true
- }
- }),
- // svg组件化支持
- svgLoader(),
- VITE_CDN ? cdn : null,
- configCompressPlugin(VITE_COMPRESSION),
- // 线上环境删除console
- removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }),
- // 打包分析
- lifecycle === "report"
- ? visualizer({ open: true, brotliSize: true, filename: "report.html" })
- : (null as any)
- ];
- }
|