UNPKG

@h0rn0chse/dark-mode-toggle

Version:
16 lines (14 loc) 546 B
import fs from "fs"; const placeholder = "STYLE_TEMPLATE"; export function replaceStyleTemplate (options) { return { name: "replaceStyleTemplate", writeBundle() { const styles = fs.readFileSync(options.src, "utf-8"); const template = `<style>${styles}</style>`; let targetContent = fs.readFileSync(options.target, "utf-8"); targetContent = targetContent.replace(/STYLE_TEMPLATE/g, template); fs.writeFileSync(options.target, targetContent, fs.w); } } }