postcss-reduce-initial
Advanced tools
Comparing version 6.0.3 to 6.1.0
{ | ||
"name": "postcss-reduce-initial", | ||
"version": "6.0.3", | ||
"version": "6.1.0", | ||
"description": "Reduce initial definitions to the actual initial value, where possible.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
'use strict'; | ||
const { dirname } = require('path'); | ||
const browserslist = require('browserslist'); | ||
@@ -6,2 +7,3 @@ const { isSupported } = require('caniuse-api'); | ||
const toInitial = require('./data/toInitial.json'); | ||
const ignoreProps = require('./lib/ignoreProps.js'); | ||
@@ -11,6 +13,11 @@ const initial = 'initial'; | ||
// In most of the browser including chrome the initial for `writing-mode` is not `horizontal-tb`. Ref https://github.com/cssnano/cssnano/pull/905 | ||
const defaultIgnoreProps = ['writing-mode', 'transform-box']; | ||
/** @typedef {{ignore?: string[]}} Options */ | ||
const defaultIgnoreProps = ignoreProps; | ||
/** | ||
* @typedef {{ overrideBrowserslist?: string | string[] }} AutoprefixerOptions | ||
* @typedef {Pick<browserslist.Options, 'stats' | 'path' | 'env'>} BrowserslistOptions | ||
* @typedef {{ignore?: string[]} & AutoprefixerOptions & BrowserslistOptions} Options | ||
*/ | ||
/** | ||
* @type {import('postcss').PluginCreator<Options>} | ||
@@ -23,9 +30,12 @@ * @param {Options} options | ||
postcssPlugin: 'postcss-reduce-initial', | ||
/** @param {import('postcss').Result & {opts: browserslist.Options & {ignore?: string[]}}} result */ | ||
/** | ||
* @param {import('postcss').Result & {opts: BrowserslistOptions & {file?: string}}} result | ||
*/ | ||
prepare(result) { | ||
const resultOpts = result.opts || {}; | ||
const browsers = browserslist(null, { | ||
stats: resultOpts.stats, | ||
path: __dirname, | ||
env: resultOpts.env, | ||
const { stats, env, from, file } = result.opts || {}; | ||
const browsers = browserslist(options.overrideBrowserslist, { | ||
stats: options.stats || stats, | ||
path: options.path || dirname(from || file || __filename), | ||
env: options.env || env, | ||
}); | ||
@@ -32,0 +42,0 @@ |
export = pluginCreator; | ||
/** @typedef {{ignore?: string[]}} Options */ | ||
/** | ||
* @typedef {{ overrideBrowserslist?: string | string[] }} AutoprefixerOptions | ||
* @typedef {Pick<browserslist.Options, 'stats' | 'path' | 'env'>} BrowserslistOptions | ||
* @typedef {{ignore?: string[]} & AutoprefixerOptions & BrowserslistOptions} Options | ||
*/ | ||
/** | ||
* @type {import('postcss').PluginCreator<Options>} | ||
@@ -10,7 +14,13 @@ * @param {Options} options | ||
declare namespace pluginCreator { | ||
export { postcss, Options }; | ||
export { postcss, AutoprefixerOptions, BrowserslistOptions, Options }; | ||
} | ||
type Options = { | ||
ignore?: string[]; | ||
} & AutoprefixerOptions & BrowserslistOptions; | ||
declare var postcss: true; | ||
type AutoprefixerOptions = { | ||
overrideBrowserslist?: string | string[]; | ||
}; | ||
declare var postcss: true; | ||
type BrowserslistOptions = Pick<browserslist.Options, 'stats' | 'path' | 'env'>; | ||
import browserslist = require("browserslist"); | ||
//# sourceMappingURL=index.d.ts.map |
18679
11
455