mirror of
https://gitee.com/yiming_chang/vue-pure-admin.git
synced 2024-11-30 02:07:38 +08:00
62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
import { cdn } from "./cdn";
|
|
import { resolve } from "path";
|
|
import vue from "@vitejs/plugin-vue";
|
|
import { viteBuildInfo } from "./info";
|
|
import svgLoader from "vite-svg-loader";
|
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
|
import { viteMockServe } from "vite-plugin-mock";
|
|
import { configCompressPlugin } from "./compress";
|
|
import { visualizer } from "rollup-plugin-visualizer";
|
|
import removeConsole from "vite-plugin-remove-console";
|
|
import themePreprocessorPlugin from "@pureadmin/theme";
|
|
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
|
|
import { genScssMultipleScopeVars } from "../src/layout/theme";
|
|
|
|
export function getPluginsList(
|
|
command: string,
|
|
VITE_CDN: boolean,
|
|
VITE_COMPRESSION: ViteCompression
|
|
) {
|
|
const prodMock = true;
|
|
const lifecycle = process.env.npm_lifecycle_event;
|
|
return [
|
|
vue(),
|
|
VueI18nPlugin({
|
|
runtimeOnly: true,
|
|
compositionOnly: true,
|
|
include: [resolve("locales/**")]
|
|
}),
|
|
// jsx、tsx语法支持
|
|
vueJsx(),
|
|
VITE_CDN ? cdn : null,
|
|
configCompressPlugin(VITE_COMPRESSION),
|
|
// 线上环境删除console
|
|
removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }),
|
|
viteBuildInfo(),
|
|
// 自定义主题
|
|
themePreprocessorPlugin({
|
|
scss: {
|
|
multipleScopeVars: genScssMultipleScopeVars(),
|
|
extract: true
|
|
}
|
|
}),
|
|
// svg组件化支持
|
|
svgLoader(),
|
|
// mock支持
|
|
viteMockServe({
|
|
mockPath: "mock",
|
|
localEnabled: command === "serve",
|
|
prodEnabled: command !== "serve" && prodMock,
|
|
injectCode: `
|
|
import { setupProdMockServer } from './mockProdServer';
|
|
setupProdMockServer();
|
|
`,
|
|
logger: false
|
|
}),
|
|
// 打包分析
|
|
lifecycle === "report"
|
|
? visualizer({ open: true, brotliSize: true, filename: "report.html" })
|
|
: null
|
|
];
|
|
}
|