Skip to content

Commit

Permalink
add banner option to gro_plugin_moss
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn committed Oct 12, 2024
1 parent 5e452cc commit 55cab52
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sweet-trainers-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ryanatkn/moss': patch
---

add `banner` option to `gro_plugin_moss`
5 changes: 4 additions & 1 deletion src/lib/gro_plugin_moss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ export interface Options {
outfile?: string;
filter_file?: File_Filter | null;
flush_debounce_delay?: number;
banner?: string;
}

export const gro_plugin_moss = ({
include_classes = null,
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,
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/routes/moss.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* generated by gro_plugin_moss */

.bg {
background-color: var(--bg);
}
Expand Down Expand Up @@ -277,3 +279,5 @@
width: 100%;
max-width: var(--width_sm);
}

/* generated by gro_plugin_moss */

0 comments on commit 55cab52

Please sign in to comment.