transformTemplate
transformTemplate(
options?):object
Defined in: index.ts:34
Rollup/Vite/Rolldown plugin that transforms text files into default-exported string literals so they can be imported directly in code.
Two categories of files are transformed:
.ymland.mdfiles — always, regardless of location (except undernode_modules).- Any non-JSON file whose resolved path contains a string listed in
dirs.
JSON files in dirs are intentionally excluded: bundlers handle .json
imports natively as typed objects, which is more useful than a raw string.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”object
name:
string="rollup-plugin-transform-template"
transform()
Section titled “transform()”transform(
_code,id): {code:string;map:null; } |null
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”{ code: string; map: null; } | null
Example
Section titled “Example”// vite.config.ts / vitest.config.ts / tsdown.config.tsimport { transformTemplate } from "@theholocron/rollup-plugin-transform-template";
plugins: [transformTemplate({ dirs: ["/src/commands/setup/templates/"] })]