babel-plugin-transform-assets-import-to-string
Version:
Babel plugin that transforms image assets import and requires to urls / cdn
28 lines (24 loc) • 924 B
text/typescript
import * as _babel_types from '@babel/types';
import { PluginObj } from '@babel/core';
interface PluginOptions {
/** Base URL prefix (e.g., "https://cdn.example.com/assets") */
baseUri?: string;
/** Directory to copy assets to (enables file copying when set) */
outputDir?: string;
/** File extensions to transform (default: ['.gif', '.jpeg', '.jpg', '.png', '.svg']) */
extensions?: string[];
/** Content hash length in filename (default: 8, set 0 to disable) */
hashLength?: number;
/** Path base to strip when preserving paths (flattens if not set) */
preservePaths?: string;
}
interface PluginState {
opts: PluginOptions;
filename: string;
cwd: string;
}
declare function plugin({ types: t, }: {
types: typeof _babel_types;
}): PluginObj<PluginState>;
declare function resetBuildCache(): void;
export { type PluginOptions, plugin as default, resetBuildCache };