Skip to content

Instantly share code, notes, and snippets.

@cyrilluce
cyrilluce / extract-components.ts
Created November 19, 2024 02:25
re-plugin vite auto-import / vue-components
import { type SFCTemplateBlock } from '@vue/compiler-sfc';
import { NodeTypes, Node, ElementNode, ElementTypes } from '@vue/compiler-core';
// 提取 vue 文件中的组件
export function extractComponents(
tpl: SFCTemplateBlock,
filter: (name: string) => boolean,
) {
const list: ElementNode[] = [];
if (!tpl) {