beesbuild
Version:
构建工具链
51 lines (50 loc) • 1.42 kB
JavaScript
import vueMacros from "unplugin-vue-macros/rollup";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import { isBoolean, mergeWith } from "lodash-unified";
function vuePlugin(options, ctx) {
var _a, _b, _c, _d;
if (((_a = options == null ? void 0 : options.vue) != null ? _a : false) === false) return [];
options = { ...options };
if (typeof (options == null ? void 0 : options.vueJsx) === "boolean") {
options.vueJsx = {};
}
if (typeof (options == null ? void 0 : options.vue) === "boolean") {
options.vue = {};
}
if (isBoolean(options == null ? void 0 : options.vueJsx)) {
options.vueJsx = {};
}
const vueJsxPlugin = vueJsx((_b = options == null ? void 0 : options.vueJsx) != null ? _b : {});
const vueOptions = mergeWith(
{
isProduction: true,
template: {
compilerOptions: {
hoistStatic: false,
cacheHandlers: false
}
}
},
(_c = options == null ? void 0 : options.vue) != null ? _c : {}
);
const vuePlugin2 = vue(vueOptions);
const plugins = {
vue: vuePlugin2,
vueJsx: vueJsxPlugin
};
const config = mergeWith(
{},
{
root: ctx.options.rootDir,
setupComponent: false,
setupSFC: false,
plugins
},
(_d = options == null ? void 0 : options.vueMacros) != null ? _d : {}
);
return vueMacros(config);
}
export {
vuePlugin
};