Skip to content

Commit

Permalink
feat(core): selectable extract function
Browse files Browse the repository at this point in the history
close #19
  • Loading branch information
TomokiMiyauci committed Mar 17, 2022
1 parent 84e19da commit c68ba46
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/generate.ts
@@ -1,5 +1,5 @@
import { isString, isUndefined, postcss, prop, Root } from "../deps.ts";
import { extractSplit } from "./extractor.ts";
import { extractBySpace } from "./extract.ts";
import { resolveConfig, resolveCSSMap, resolveModifierMap } from "./resolve.ts";
import { escapeSelector } from "./utils/escape.ts";
import {
Expand Down Expand Up @@ -53,6 +53,7 @@ export function generate(
variablePrefix = VARIABLE_PREFIX,
charMap = CHAR_MAP,
minify = false,
extract = extractBySpace,
...staticConfig
}: Readonly<
Partial<
Expand All @@ -66,6 +67,7 @@ export function generate(
variablePrefix,
charMap,
minify,
extract,
};
const {
syntax,
Expand All @@ -80,7 +82,7 @@ export function generate(
...ctx,
theme,
};
const tokens = isString(input) ? extractSplit(input) : input;
const tokens = isString(input) ? extract(input) : input;
const matched = new Set<string>();
const unmatched = new Set<string>();

Expand Down
5 changes: 5 additions & 0 deletions core/types.ts
Expand Up @@ -69,6 +69,11 @@ export type StaticContext = {
* @default false
*/
minify: boolean;

/** Extract token
* @default [Function: extractBySpace]
*/
extract: (value: string) => Set<string>;
};

export type RuntimeContext = {
Expand Down

0 comments on commit c68ba46

Please sign in to comment.