@varlinor/builder-vue3
Version:
This package provides a set of Rollup and Vite configurations and utility functions tailored for Vue.js development environments, focusing on simplifying the build process for front-end development. It includes modules for configuring Rollup and Vite for
53 lines (48 loc) • 1.46 kB
JavaScript
;
const plugins = require('@varlinor/node-tools/plugins');
function createRewriteHook(packageRoot, scopes, exts, subPackageBase = "packages/") {
return (ctx, opts) => {
const { plugins: plugins$1 } = opts;
if (Array.isArray(plugins$1)) {
const plugin = plugins.resolveDirImport({
basePath: packageRoot,
exts,
scopes,
subPackageBase
});
const idx = plugins$1.findIndex((p) => {
return !!p && typeof p === "object" && "name" in p && p.name === "unbuild-raw";
});
if (idx >= 0) {
opts.plugins.splice(idx, 0, plugin);
}
}
};
}
function createRewritePlugin(packageRoot, scopes, exts, subPackageBase = "packages/") {
return plugins.resolveDirImport({
basePath: packageRoot,
exts,
scopes,
subPackageBase
});
}
function createGlobResolveHook(packageRoot) {
return (ctx, opts) => {
const { plugins: plugins$1 } = opts;
if (Array.isArray(plugins$1)) {
const plugin = plugins.resolveGlobImports({
basePath: packageRoot
});
const idx = plugins$1.findIndex((p) => {
return !!p && typeof p === "object" && "name" in p && p.name === "unbuild-raw";
});
if (idx >= 0) {
opts.plugins.splice(idx, 0, plugin);
}
}
};
}
exports.createGlobResolveHook = createGlobResolveHook;
exports.createRewriteHook = createRewriteHook;
exports.createRewritePlugin = createRewritePlugin;