From 55cab52b20d319ce27ee4757c1e11c43ac6598c9 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Sat, 12 Oct 2024 10:08:26 -0600 Subject: [PATCH] add `banner` option to `gro_plugin_moss` --- .changeset/sweet-trainers-clean.md | 5 +++++ src/lib/gro_plugin_moss.ts | 5 ++++- src/routes/moss.css | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/sweet-trainers-clean.md diff --git a/.changeset/sweet-trainers-clean.md b/.changeset/sweet-trainers-clean.md new file mode 100644 index 00000000..16f7601b --- /dev/null +++ b/.changeset/sweet-trainers-clean.md @@ -0,0 +1,5 @@ +--- +'@ryanatkn/moss': patch +--- + +add `banner` option to `gro_plugin_moss` diff --git a/src/lib/gro_plugin_moss.ts b/src/lib/gro_plugin_moss.ts index 29ab004d..cd5f1069 100644 --- a/src/lib/gro_plugin_moss.ts +++ b/src/lib/gro_plugin_moss.ts @@ -43,6 +43,7 @@ export interface Options { outfile?: string; filter_file?: File_Filter | null; flush_debounce_delay?: number; + banner?: string; } export const gro_plugin_moss = ({ @@ -50,6 +51,7 @@ export const gro_plugin_moss = ({ outfile = 'src/routes/moss.css', // TODO maybe support multiple files using file filters to check where to collect them? filter_file = (p) => !p.includes('.test.') && !p.includes('/test/'), flush_debounce_delay = FLUSH_DEBOUNCE_DELAY, + banner = 'generated by gro_plugin_moss', }: Options = EMPTY_OBJECT): Plugin => { const css_classes = new Css_Classes( Array.isArray(include_classes) ? new Set(include_classes) : include_classes, @@ -69,7 +71,8 @@ export const gro_plugin_moss = ({ const flush_gen_queue = throttle( async () => { const css = generate_classes_css(css_classes.get_sorted_array()); - const output = await format_file(css, {filepath: outfile}); + const contents = `/* ${banner} */\n\n${css}\n\n/* ${banner} */n`; + const output = await format_file(contents, {filepath: outfile}); // TODO think about using gen to implement this, would have some nice benefits like automatic change detection if (output === previous_output) return; previous_output = output; diff --git a/src/routes/moss.css b/src/routes/moss.css index 10ca5aeb..5ceff842 100644 --- a/src/routes/moss.css +++ b/src/routes/moss.css @@ -1,3 +1,5 @@ +/* generated by gro_plugin_moss */ + .bg { background-color: var(--bg); } @@ -277,3 +279,5 @@ width: 100%; max-width: var(--width_sm); } + +/* generated by gro_plugin_moss */