UNPKG

esbuild-raw-plugin

Version:

An ESBuild and TSUP plugin that allows importing files as raw text. Useful for loading code files in documentation, interactive demos, or tools like react-live.

27 lines (26 loc) 946 B
import type { Plugin } from "esbuild"; export interface RawPluginOptions { /** * File extensions to check in order of priority if the specified file is missing. * If it's a directory, the plugin will look for `dir/index.[ext]`. * @defaultValue ["ts", "tsx", "js", "jsx", "mjs", "mts", "module.css", "module.scss", "css", "scss"] */ ext?: string[]; /** * Custom loader for file processing. * @defaultValue "text" */ loader?: "text" | "base64" | "dataurl" | "file" | "binary" | "default"; /** * Extensions to be treated as text files. */ textExtensions?: string[]; } /** * ESBuild plugin to enable raw file imports. * * This plugin allows importing files with a `?raw` suffix, * treating them as raw text content. It supports resolving file * extensions in order of priority and handling custom loaders. */ export declare const raw: (options?: RawPluginOptions) => Plugin;