diff options
Diffstat (limited to 'node_modules/postcss-normalize-unicode/src/index.js')
| -rw-r--r-- | node_modules/postcss-normalize-unicode/src/index.js | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/node_modules/postcss-normalize-unicode/src/index.js b/node_modules/postcss-normalize-unicode/src/index.js index d8a562b8..2285fc52 100644 --- a/node_modules/postcss-normalize-unicode/src/index.js +++ b/node_modules/postcss-normalize-unicode/src/index.js @@ -1,4 +1,5 @@ 'use strict'; +const { dirname } = require('path'); const browserslist = require('browserslist'); const valueParser = require('postcss-value-parser'); @@ -89,21 +90,32 @@ function transform(value, isLegacy = false) { } /** - * @type {import('postcss').PluginCreator<void>} + * @typedef {{ overrideBrowserslist?: string | string[] }} AutoprefixerOptions + * @typedef {Pick<browserslist.Options, 'stats' | 'path' | 'env'>} BrowserslistOptions + * @typedef {AutoprefixerOptions & BrowserslistOptions} Options + */ + +/** + * @type {import('postcss').PluginCreator<Options>} + * @param {Options} opts * @return {import('postcss').Plugin} */ -function pluginCreator() { +function pluginCreator(opts = {}) { return { postcssPlugin: 'postcss-normalize-unicode', - /** @param {import('postcss').Result & {opts: browserslist.Options}} result*/ + + /** + * @param {import('postcss').Result & {opts: BrowserslistOptions & {file?: string}}} result + */ prepare(result) { - const cache = new Map(); - 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(opts.overrideBrowserslist, { + stats: opts.stats || stats, + path: opts.path || dirname(from || file || __filename), + env: opts.env || env, }); + + const cache = new Map(); const isLegacy = browsers.some(hasLowerCaseUPrefixBug); return { |
