Skip to content

Commit

Permalink
fix(cli): Preflight not working with CLI, close #514 (#673)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Schut <martin-gitlab@wommm.nl>
  • Loading branch information
schutm and Martin Schut committed Feb 22, 2022
1 parent 011dd5d commit 26a6c71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/lib/index.ts
Expand Up @@ -104,6 +104,12 @@ export class Processor {
this._handler = createHandler(this._config.handlers);
this._config.shortcuts && this.loadShortcuts(this._config.shortcuts);
this._config.alias && this.loadAlias(this._config.alias);

if (this._config.preflight && this._config.preflight.safelist) {
if (typeof this._config.preflight.safelist === 'string') {
this._config.preflight.safelist = this._config.preflight.safelist.split(/\s+/);
}
}
}

private _resolveConfig(userConfig: Config, presets: Config = {}) {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/preflight.ts
Expand Up @@ -33,7 +33,8 @@ export default function preflight(
return style;
};

const tags = html ? Array.from(new Set(html.match(/<\w+/g))).map((i) => i.substring(1)) : undefined;
const safelist = processor.config('preflight.safelist', []) as string[];
const tags = html ? safelist.concat(Array.from(new Set(html.match(/<\w+/g))).map((i) => i.substring(1))) : undefined;

// handle base style
includeBase && (processor.config('prefixer') ? baseUtilities : baseUtilities.filter(i => !i.selector || !/::?(webkit-input|-moz|-ms-input)-placeholder$/.test(i.selector))).forEach(p => {
Expand Down

0 comments on commit 26a6c71

Please sign in to comment.