2022-12-16 17:26:54 +08:00
|
|
|
import vue from "@vitejs/plugin-vue";
|
2021-11-30 09:55:37 +08:00
|
|
|
|
2022-12-16 17:26:54 +08:00
|
|
|
import createAutoImport from "./auto-import";
|
|
|
|
import createSvgIcon from "./svg-icon";
|
|
|
|
import createCompression from "./compression";
|
|
|
|
import createSetupExtend from "./setup-extend";
|
|
|
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
2022-12-20 16:32:39 +08:00
|
|
|
import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
2021-11-30 09:55:37 +08:00
|
|
|
|
|
|
|
export default function createVitePlugins(viteEnv, isBuild = false) {
|
2022-12-16 17:26:54 +08:00
|
|
|
const vitePlugins = [
|
|
|
|
vue(),
|
|
|
|
vueJsx({
|
|
|
|
transformOn: true,
|
|
|
|
// include: ["src/**/*.vue", "src/**/*.jsx"],
|
|
|
|
}),
|
2022-12-20 16:32:39 +08:00
|
|
|
nodePolyfills({
|
|
|
|
// Whether to polyfill `node:` protocol imports.
|
|
|
|
protocolImports: true,
|
|
|
|
}),
|
2022-12-16 17:26:54 +08:00
|
|
|
];
|
|
|
|
vitePlugins.push(createAutoImport());
|
|
|
|
vitePlugins.push(createSetupExtend());
|
|
|
|
vitePlugins.push(createSvgIcon(isBuild));
|
|
|
|
isBuild && vitePlugins.push(...createCompression(viteEnv));
|
|
|
|
return vitePlugins;
|
2021-11-30 09:55:37 +08:00
|
|
|
}
|