Skip to content

Commit

Permalink
fix: add skipResets flag (#142)
Browse files Browse the repository at this point in the history
Co-authored-by: AnnaRybkina <anna.rybkina@schibsted.com>
  • Loading branch information
AnnaRybkina and anna-rybkina committed Jul 7, 2023
1 parent 829630f commit a13cbcd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
- `boolean`
- Internal use only - force preflights(resets.css + transform resets) to be excluded and no externalized classes will be processed

### skipResets

- `boolean`
- If true forces resets to be excluded from preflights

### omitComponentClasses

- `boolean`
Expand Down
2 changes: 1 addition & 1 deletion src/_preflights/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { transformBase } from './transform.js';
import { resets } from './resets.js';

export const preflights = [transformBase, resets];
export const preflights = (skipResets) => (skipResets ? [transformBase] : [transformBase, resets]);
13 changes: 8 additions & 5 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ import { postprocess } from '#postprocess';
/**
* @typedef PluginOptions
* @type {Object}
* @property {boolean} development // internal use only - force preflights to be excluded and no external classes will be processed
* @property {boolean} development // internal use only - force preflights(transform + resets) to be excluded and no external classes will be processed
* @property {boolean} skipResets // force resets to be excluded from preflights
* @property {boolean} externalizeClasses - if true forces external or 'core' classes to be excluded from the process.
* @property {boolean} omitComponentClasses - if true forces component classes to be excluded from the process.
* @property {Array} externalClasses - list of classes that will not be processed
* @property {boolean} usePixels - use pixel spacing instead of rem
*/

// TODO: improve generic type passed here
/** @type {import('@unocss/core').Preset<object>} */
export function presetWarp (options = {}) {
/**
* @param {PluginOptions} options
* @type {import('@unocss/core').Preset}
*/
export function presetWarp(options = {}) {
checkEnvironment();
const externalizeClasses = options.externalizeClasses ?? !options.development; // 'true' by default
const safeExternalClasses = options.externalClasses || [];
Expand All @@ -28,7 +31,7 @@ export function presetWarp (options = {}) {
theme,
rules,
variants,
preflights: options.development ? [] : preflights,
preflights: options.development ? [] : preflights(options.skipResets),
postprocess: postprocess(externalizeClasses, excludedClasses),
shortcuts,
};
Expand Down

0 comments on commit a13cbcd

Please sign in to comment.