UNPKG

vite-inset-loader

Version:

在Vite构建的Vue应用中,编译阶段在SFC模板指定位置插入自定义内容,适用于需要在每个页面引入组件的小程序场景。

49 lines (44 loc) 1.73 kB
import { PluginOption } from 'vite'; import { SFCScriptBlock } from '@vue/compiler-sfc'; interface InsetLoaderConfig { label?: string[]; config?: Record<string, any>; package?: ViteInsetLoaderOptions; } interface LabelConfig { [key: string]: { label?: string[]; package?: ViteInsetLoaderOptions; }; } interface ViteInsetLoaderOptions { label: string; options: { class?: string; id?: string; style: { [key: string]: string; }; [key: string]: any; }; } interface OPTIONS { include?: string | string[]; } /** * Vite 插件入口函数,返回插件配置对象。 * @returns 插件配置对象。 */ declare const viteInsetLoader: (options?: OPTIONS) => PluginOption; declare const generateLabelCode: (labelArr: string[]) => string; declare const initPages: (that: any) => boolean; declare const getPagesMap: () => { [key: string]: LabelConfig; }; declare const generateHtmlCode: (template: string, labelCode: string, packageEle: ViteInsetLoaderOptions | null) => string; declare const generateStyleCode: (styles: any[]) => any; declare const generateScriptCode: (script: SFCScriptBlock) => string; declare const getRoute: (resourcePath: string) => string | null; declare const filterDirectoriesByInclude: (rootDir: string, options: OPTIONS) => string[]; declare const getTemplatePageMeta: (template: string) => string; export { InsetLoaderConfig, LabelConfig, OPTIONS, ViteInsetLoaderOptions, viteInsetLoader as default, filterDirectoriesByInclude, generateHtmlCode, generateLabelCode, generateScriptCode, generateStyleCode, getPagesMap, getRoute, getTemplatePageMeta, initPages };