vite-awesome-svg-loader
Version:
A universal Vite SVG loader. Imports SVGs as source code, base64 and data URI. Preserves stroke width. Replaces colors with currentColor or custom colors. Creates SVG sprites. Optimizes SVGs.
50 lines (49 loc) • 2.3 kB
TypeScript
import { XastChild } from 'svgo/lib/types';
import { ColorMapPerFiles, CssSelectors, FileMatcherFnContext, FileMatchers } from '../types';
import { ResolvedColorReplacements } from './types';
export declare function normalizeBaseDir(dir: string): string;
export declare function toBase64(str: string): string;
/**
* Escapes backticks in a string with a slash: \\\`
*/
export declare function escapeBackticks(str: string): string;
export interface MatchesQueryOrListOptions extends MatchesPathOptions {
queryValue?: string;
}
/**
* Checks if given relative path or filename matches query value or a list of matchers
* @param relPathWithSlash Relative path with leading slash
* @param queryValue Value of a query param to check. If value exists and not equals to `false` (case-insensitive),
* function returns `true`.
* @param matchers List of matchers to check path and filename against
*/
export declare function matchesQueryOrPath(options: MatchesQueryOrListOptions): boolean;
export declare function matchesQuery(queryValue: string | undefined): boolean;
export interface MatchesPathOptions extends FileMatcherFnContext {
matchers: FileMatchers;
}
/**
* Checks if given relative path or filename matches a list of matchers
* @param relPathWithSlash Relative path with leading slash
* @param matchers List of matchers to check path and filename against
*/
export declare function matchesPath(options: MatchesPathOptions): boolean;
export interface SelectorsToListOptions extends FileMatcherFnContext {
selectors: CssSelectors;
}
/**
* Converts CSS selectors to a list and normalizes each selector
* @param relPathWithSlash Relative path with leading slash
* @param selectors Selectors
*/
export declare function selectorsToList(options: SelectorsToListOptions): string[];
/**
* Checks if a node matches a selector
*/
export declare const matchesSelector: (node: XastChild, selector: string) => boolean;
/**
* Checks if a node matches at least one CSS selector in a list
*/
export declare function matchesSelectors(node: XastChild, selectors: string[]): boolean;
export declare function replaceColor(color: string | undefined, replacements: ResolvedColorReplacements): string;
export declare function isColorMapPerFiles(value: unknown): value is ColorMapPerFiles;