2022-10-26 19:44:44 +08:00
|
|
|
import { cdn } from "./cdn";
|
2022-03-11 21:28:43 +08:00
|
|
|
import { resolve } from "path";
|
2022-02-05 17:34:01 +08:00
|
|
|
import vue from "@vitejs/plugin-vue";
|
2022-02-27 02:44:29 +08:00
|
|
|
import { viteBuildInfo } from "./info";
|
2022-02-05 17:34:01 +08:00
|
|
|
import svgLoader from "vite-svg-loader";
|
|
|
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
2022-10-27 02:35:56 +08:00
|
|
|
import { configCompressPlugin } from "./compress";
|
2022-02-05 17:34:01 +08:00
|
|
|
import { visualizer } from "rollup-plugin-visualizer";
|
|
|
|
import removeConsole from "vite-plugin-remove-console";
|
2023-10-22 14:59:47 +08:00
|
|
|
import { themePreprocessorPlugin } from "@pureadmin/theme";
|
2022-12-19 11:58:49 +08:00
|
|
|
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
|
2022-10-27 12:43:01 +08:00
|
|
|
import { genScssMultipleScopeVars } from "../src/layout/theme";
|
2023-11-10 12:33:22 +08:00
|
|
|
import { vitePluginFakeServer } from "vite-plugin-fake-server";
|
2022-02-05 17:34:01 +08:00
|
|
|
|
2022-10-26 19:44:44 +08:00
|
|
|
export function getPluginsList(
|
|
|
|
command: string,
|
2022-10-27 02:35:56 +08:00
|
|
|
VITE_CDN: boolean,
|
|
|
|
VITE_COMPRESSION: ViteCompression
|
2022-10-26 19:44:44 +08:00
|
|
|
) {
|
2022-02-05 17:34:01 +08:00
|
|
|
const lifecycle = process.env.npm_lifecycle_event;
|
|
|
|
return [
|
|
|
|
vue(),
|
2022-12-19 11:58:49 +08:00
|
|
|
VueI18nPlugin({
|
2022-03-11 21:28:43 +08:00
|
|
|
runtimeOnly: true,
|
|
|
|
compositionOnly: true,
|
|
|
|
include: [resolve("locales/**")]
|
|
|
|
}),
|
2022-02-05 17:34:01 +08:00
|
|
|
// jsx、tsx语法支持
|
|
|
|
vueJsx(),
|
2022-10-26 19:44:44 +08:00
|
|
|
VITE_CDN ? cdn : null,
|
2022-10-27 02:35:56 +08:00
|
|
|
configCompressPlugin(VITE_COMPRESSION),
|
2022-02-05 17:34:01 +08:00
|
|
|
// 线上环境删除console
|
2022-06-22 21:36:48 +08:00
|
|
|
removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }),
|
2022-02-27 02:44:29 +08:00
|
|
|
viteBuildInfo(),
|
2022-02-05 17:34:01 +08:00
|
|
|
// 自定义主题
|
|
|
|
themePreprocessorPlugin({
|
|
|
|
scss: {
|
2022-03-30 12:27:51 +08:00
|
|
|
multipleScopeVars: genScssMultipleScopeVars(),
|
2022-12-15 12:28:51 +08:00
|
|
|
extract: true
|
2022-02-05 17:34:01 +08:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
// svg组件化支持
|
|
|
|
svgLoader(),
|
|
|
|
// mock支持
|
2023-11-10 12:33:22 +08:00
|
|
|
vitePluginFakeServer({
|
|
|
|
logger: false,
|
|
|
|
include: "mock",
|
|
|
|
infixName: false,
|
|
|
|
enableProd: true
|
2022-02-05 17:34:01 +08:00
|
|
|
}),
|
|
|
|
// 打包分析
|
|
|
|
lifecycle === "report"
|
|
|
|
? visualizer({ open: true, brotliSize: true, filename: "report.html" })
|
|
|
|
: null
|
|
|
|
];
|
|
|
|
}
|