UNPKG

@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

49 lines (45 loc) 1.34 kB
import { resolveDirImport, resolveGlobImports } from '@varlinor/node-tools/plugins'; function createRewriteHook(packageRoot, scopes, exts, subPackageBase = "packages/") { return (ctx, opts) => { const { plugins } = opts; if (Array.isArray(plugins)) { const plugin = resolveDirImport({ basePath: packageRoot, exts, scopes, subPackageBase }); const idx = plugins.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 resolveDirImport({ basePath: packageRoot, exts, scopes, subPackageBase }); } function createGlobResolveHook(packageRoot) { return (ctx, opts) => { const { plugins } = opts; if (Array.isArray(plugins)) { const plugin = resolveGlobImports({ basePath: packageRoot }); const idx = plugins.findIndex((p) => { return !!p && typeof p === "object" && "name" in p && p.name === "unbuild-raw"; }); if (idx >= 0) { opts.plugins.splice(idx, 0, plugin); } } }; } export { createGlobResolveHook, createRewriteHook, createRewritePlugin };