index.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. 'use strict';
  2. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  3. var autoprefixer = _interopDefault(require('autoprefixer'));
  4. var browserslist = _interopDefault(require('browserslist'));
  5. var cssdb = _interopDefault(require('cssdb'));
  6. var postcss$1 = _interopDefault(require('postcss'));
  7. var postcssAttributeCaseInsensitive = _interopDefault(require('postcss-attribute-case-insensitive'));
  8. var postcssBlankPseudo = _interopDefault(require('css-blank-pseudo/postcss'));
  9. var postcssColorFunctionalNotation = _interopDefault(require('postcss-color-functional-notation'));
  10. var postcssColorGray = _interopDefault(require('postcss-color-gray'));
  11. var postcssColorHexAlpha = _interopDefault(require('postcss-color-hex-alpha'));
  12. var postcssColorModFunction = _interopDefault(require('postcss-color-mod-function'));
  13. var postcssColorRebeccapurple = _interopDefault(require('postcss-color-rebeccapurple'));
  14. var postcssCustomMedia = _interopDefault(require('postcss-custom-media'));
  15. var postcssCustomProperties = _interopDefault(require('postcss-custom-properties'));
  16. var postcssCustomSelectors = _interopDefault(require('postcss-custom-selectors'));
  17. var postcssDirPseudoClass = _interopDefault(require('postcss-dir-pseudo-class'));
  18. var postcssDoublePositionGradients = _interopDefault(require('postcss-double-position-gradients'));
  19. var postcssEnvFunction = _interopDefault(require('postcss-env-function'));
  20. var postcssFocusVisible = _interopDefault(require('postcss-focus-visible'));
  21. var postcssFocusWithin = _interopDefault(require('postcss-focus-within'));
  22. var postcssFontVariant = _interopDefault(require('postcss-font-variant'));
  23. var postcssGapProperties = _interopDefault(require('postcss-gap-properties'));
  24. var postcssHasPseudo = _interopDefault(require('css-has-pseudo/postcss'));
  25. var postcssImageSetPolyfill = _interopDefault(require('postcss-image-set-function'));
  26. var postcssInitial = _interopDefault(require('postcss-initial'));
  27. var postcssLabFunction = _interopDefault(require('postcss-lab-function'));
  28. var postcssLogical = _interopDefault(require('postcss-logical'));
  29. var postcssMediaMinmax = _interopDefault(require('postcss-media-minmax'));
  30. var postcssNesting = _interopDefault(require('postcss-nesting'));
  31. var postcssOverflowShorthand = _interopDefault(require('postcss-overflow-shorthand'));
  32. var postcssPageBreak = _interopDefault(require('postcss-page-break'));
  33. var postcssPlace = _interopDefault(require('postcss-place'));
  34. var postcssPrefersColorScheme = _interopDefault(require('css-prefers-color-scheme/postcss'));
  35. var postcssPseudoClassAnyLink = _interopDefault(require('postcss-pseudo-class-any-link'));
  36. var postcssReplaceOverflowWrap = _interopDefault(require('postcss-replace-overflow-wrap'));
  37. var postcssSelectorMatches = _interopDefault(require('postcss-selector-matches'));
  38. var postcssSelectorNot = _interopDefault(require('postcss-selector-not'));
  39. var caniuse = require('caniuse-lite');
  40. var fs = _interopDefault(require('fs'));
  41. var path = _interopDefault(require('path'));
  42. var postcssFontFamilySystemUi = postcss$1.plugin('postcss-system-ui-font', () => root => {
  43. root.walkDecls(propertyRegExp, decl => {
  44. decl.value = decl.value.replace(systemUiMatch, systemUiReplace);
  45. });
  46. });
  47. const propertyRegExp = /(?:^(?:-|\\002d){2})|(?:^font(?:-family)?$)/i;
  48. const whitespace = '[\\f\\n\\r\\x09\\x20]';
  49. const systemUiFamily = ['system-ui',
  50. /* macOS 10.11-10.12 */
  51. '-apple-system',
  52. /* Windows 6+ */
  53. 'Segoe UI',
  54. /* Android 4+ */
  55. 'Roboto',
  56. /* Ubuntu 10.10+ */
  57. 'Ubuntu',
  58. /* Gnome 3+ */
  59. 'Cantarell',
  60. /* KDE Plasma 5+ */
  61. 'Noto Sans',
  62. /* fallback */
  63. 'sans-serif'];
  64. const systemUiMatch = new RegExp(`(^|,|${whitespace}+)(?:system-ui${whitespace}*)(?:,${whitespace}*(?:${systemUiFamily.join('|')})${whitespace}*)?(,|$)`, 'i');
  65. const systemUiReplace = `$1${systemUiFamily.join(', ')}$2`;
  66. var plugins = {
  67. 'all-property': postcssInitial,
  68. 'any-link-pseudo-class': postcssPseudoClassAnyLink,
  69. 'blank-pseudo-class': postcssBlankPseudo,
  70. 'break-properties': postcssPageBreak,
  71. 'case-insensitive-attributes': postcssAttributeCaseInsensitive,
  72. 'color-functional-notation': postcssColorFunctionalNotation,
  73. 'color-mod-function': postcssColorModFunction,
  74. 'custom-media-queries': postcssCustomMedia,
  75. 'custom-properties': postcssCustomProperties,
  76. 'custom-selectors': postcssCustomSelectors,
  77. 'dir-pseudo-class': postcssDirPseudoClass,
  78. 'double-position-gradients': postcssDoublePositionGradients,
  79. 'environment-variables': postcssEnvFunction,
  80. 'focus-visible-pseudo-class': postcssFocusVisible,
  81. 'focus-within-pseudo-class': postcssFocusWithin,
  82. 'font-variant-property': postcssFontVariant,
  83. 'gap-properties': postcssGapProperties,
  84. 'gray-function': postcssColorGray,
  85. 'has-pseudo-class': postcssHasPseudo,
  86. 'hexadecimal-alpha-notation': postcssColorHexAlpha,
  87. 'image-set-function': postcssImageSetPolyfill,
  88. 'lab-function': postcssLabFunction,
  89. 'logical-properties-and-values': postcssLogical,
  90. 'matches-pseudo-class': postcssSelectorMatches,
  91. 'media-query-ranges': postcssMediaMinmax,
  92. 'nesting-rules': postcssNesting,
  93. 'not-pseudo-class': postcssSelectorNot,
  94. 'overflow-property': postcssOverflowShorthand,
  95. 'overflow-wrap-property': postcssReplaceOverflowWrap,
  96. 'place-properties': postcssPlace,
  97. 'prefers-color-scheme-query': postcssPrefersColorScheme,
  98. 'rebeccapurple-color': postcssColorRebeccapurple,
  99. 'system-ui-font-family': postcssFontFamilySystemUi
  100. };
  101. // return a list of features to be inserted before or after cssdb features
  102. function getTransformedInsertions(insertions, placement) {
  103. return Object.keys(insertions).map(id => [].concat(insertions[id]).map(plugin => ({
  104. [placement]: true,
  105. plugin,
  106. id
  107. }))).reduce((array, feature) => array.concat(feature), []);
  108. }
  109. function getUnsupportedBrowsersByFeature(feature) {
  110. const caniuseFeature = caniuse.features[feature]; // if feature support can be determined
  111. if (caniuseFeature) {
  112. const stats = caniuse.feature(caniuseFeature).stats; // return an array of browsers and versions that do not support the feature
  113. const results = Object.keys(stats).reduce((browsers, browser) => browsers.concat(Object.keys(stats[browser]).filter(version => stats[browser][version].indexOf('y') !== 0).map(version => `${browser} ${version}`)), []);
  114. return results;
  115. } else {
  116. // otherwise, return that the feature does not work in any browser
  117. return ['> 0%'];
  118. }
  119. }
  120. // ids ordered by required execution, then alphabetically
  121. var idsByExecutionOrder = ['custom-media-queries', 'custom-properties', 'environment-variables', // run environment-variables here to access transpiled custom media params and properties
  122. 'image-set-function', // run images-set-function before nesting-rules so that it may fix nested media
  123. 'media-query-ranges', // run media-query-range and
  124. 'prefers-color-scheme-query', // run prefers-color-scheme-query here to prevent duplicate transpilation after nesting-rules
  125. 'nesting-rules', 'custom-selectors', // run custom-selectors after nesting-rules to correctly transpile &:--custom-selector
  126. 'any-link-pseudo-class', 'case-insensitive-attributes', 'focus-visible-pseudo-class', 'focus-within-pseudo-class', 'matches-pseudo-class', // run matches-pseudo-class and
  127. 'not-pseudo-class', // run not-pseudo-class after other selectors have been transpiled
  128. 'logical-properties-and-values', // run logical-properties-and-values before dir-pseudo-class
  129. 'dir-pseudo-class', 'all-property', // run all-property before other property polyfills
  130. 'color-functional-notation', 'double-position-gradients', 'gray-function', 'hexadecimal-alpha-notation', 'lab-function', 'rebeccapurple-color', 'color-mod-function', // run color-mod after other color modifications have finished
  131. 'blank-pseudo-class', 'break-properties', 'font-variant-property', 'has-pseudo-class', 'gap-properties', 'overflow-property', 'overflow-wrap-property', 'place-properties', 'system-ui-font-family'];
  132. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  133. try {
  134. var info = gen[key](arg);
  135. var value = info.value;
  136. } catch (error) {
  137. reject(error);
  138. return;
  139. }
  140. if (info.done) {
  141. resolve(value);
  142. } else {
  143. Promise.resolve(value).then(_next, _throw);
  144. }
  145. }
  146. function _asyncToGenerator(fn) {
  147. return function () {
  148. var self = this,
  149. args = arguments;
  150. return new Promise(function (resolve, reject) {
  151. var gen = fn.apply(self, args);
  152. function _next(value) {
  153. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  154. }
  155. function _throw(err) {
  156. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  157. }
  158. _next(undefined);
  159. });
  160. };
  161. }
  162. /* Write Exports to CSS File
  163. /* ========================================================================== */
  164. function getCustomMediaAsCss(customMedia) {
  165. const cssContent = Object.keys(customMedia).reduce((cssLines, name) => {
  166. cssLines.push(`@custom-media ${name} ${customMedia[name]};`);
  167. return cssLines;
  168. }, []).join('\n');
  169. const css = `${cssContent}\n`;
  170. return css;
  171. }
  172. function getCustomPropertiesAsCss(customProperties) {
  173. const cssContent = Object.keys(customProperties).reduce((cssLines, name) => {
  174. cssLines.push(`\t${name}: ${customProperties[name]};`);
  175. return cssLines;
  176. }, []).join('\n');
  177. const css = `:root {\n${cssContent}\n}\n`;
  178. return css;
  179. }
  180. function getCustomSelectorsAsCss(customSelectors) {
  181. const cssContent = Object.keys(customSelectors).reduce((cssLines, name) => {
  182. cssLines.push(`@custom-selector ${name} ${customSelectors[name]};`);
  183. return cssLines;
  184. }, []).join('\n');
  185. const css = `${cssContent}\n`;
  186. return css;
  187. }
  188. function writeExportsToCssFile(_x, _x2, _x3, _x4) {
  189. return _writeExportsToCssFile.apply(this, arguments);
  190. }
  191. /* Write Exports to JSON file
  192. /* ========================================================================== */
  193. function _writeExportsToCssFile() {
  194. _writeExportsToCssFile = _asyncToGenerator(function* (to, customMedia, customProperties, customSelectors) {
  195. const customPropertiesAsCss = getCustomPropertiesAsCss(customProperties);
  196. const customMediaAsCss = getCustomMediaAsCss(customMedia);
  197. const customSelectorsAsCss = getCustomSelectorsAsCss(customSelectors);
  198. const css = `${customMediaAsCss}\n${customSelectorsAsCss}\n${customPropertiesAsCss}`;
  199. yield writeFile(to, css);
  200. });
  201. return _writeExportsToCssFile.apply(this, arguments);
  202. }
  203. function writeExportsToJsonFile(_x5, _x6, _x7, _x8) {
  204. return _writeExportsToJsonFile.apply(this, arguments);
  205. }
  206. /* Write Exports to Common JS file
  207. /* ========================================================================== */
  208. function _writeExportsToJsonFile() {
  209. _writeExportsToJsonFile = _asyncToGenerator(function* (to, customMedia, customProperties, customSelectors) {
  210. const jsonContent = JSON.stringify({
  211. 'custom-media': customMedia,
  212. 'custom-properties': customProperties,
  213. 'custom-selectors': customSelectors
  214. }, null, ' ');
  215. const json = `${jsonContent}\n`;
  216. yield writeFile(to, json);
  217. });
  218. return _writeExportsToJsonFile.apply(this, arguments);
  219. }
  220. function getObjectWithKeyAsCjs(key, object) {
  221. const jsContents = Object.keys(object).reduce((jsLines, name) => {
  222. jsLines.push(`\t\t'${escapeForJS(name)}': '${escapeForJS(object[name])}'`);
  223. return jsLines;
  224. }, []).join(',\n');
  225. const cjs = `\n\t${key}: {\n${jsContents}\n\t}`;
  226. return cjs;
  227. }
  228. function writeExportsToCjsFile(_x9, _x10, _x11, _x12) {
  229. return _writeExportsToCjsFile.apply(this, arguments);
  230. }
  231. /* Write Exports to Module JS file
  232. /* ========================================================================== */
  233. function _writeExportsToCjsFile() {
  234. _writeExportsToCjsFile = _asyncToGenerator(function* (to, customMedia, customProperties, customSelectors) {
  235. const customMediaAsCjs = getObjectWithKeyAsCjs('customMedia', customMedia);
  236. const customPropertiesAsCjs = getObjectWithKeyAsCjs('customProperties', customProperties);
  237. const customSelectorsAsCjs = getObjectWithKeyAsCjs('customSelectors', customSelectors);
  238. const cjs = `module.exports = {${customMediaAsCjs},${customPropertiesAsCjs},${customSelectorsAsCjs}\n};\n`;
  239. yield writeFile(to, cjs);
  240. });
  241. return _writeExportsToCjsFile.apply(this, arguments);
  242. }
  243. function getObjectWithKeyAsMjs(key, object) {
  244. const mjsContents = Object.keys(object).reduce((mjsLines, name) => {
  245. mjsLines.push(`\t'${escapeForJS(name)}': '${escapeForJS(object[name])}'`);
  246. return mjsLines;
  247. }, []).join(',\n');
  248. const mjs = `export const ${key} = {\n${mjsContents}\n};\n`;
  249. return mjs;
  250. }
  251. function writeExportsToMjsFile(_x13, _x14, _x15, _x16) {
  252. return _writeExportsToMjsFile.apply(this, arguments);
  253. }
  254. /* Write Exports to Exports
  255. /* ========================================================================== */
  256. function _writeExportsToMjsFile() {
  257. _writeExportsToMjsFile = _asyncToGenerator(function* (to, customMedia, customProperties, customSelectors) {
  258. const customMediaAsMjs = getObjectWithKeyAsMjs('customMedia', customMedia);
  259. const customPropertiesAsMjs = getObjectWithKeyAsMjs('customProperties', customProperties);
  260. const customSelectorsAsMjs = getObjectWithKeyAsMjs('customSelectors', customSelectors);
  261. const mjs = `${customMediaAsMjs}\n${customPropertiesAsMjs}\n${customSelectorsAsMjs}`;
  262. yield writeFile(to, mjs);
  263. });
  264. return _writeExportsToMjsFile.apply(this, arguments);
  265. }
  266. function writeToExports(customExports, destinations) {
  267. return Promise.all([].concat(destinations).map( /*#__PURE__*/function () {
  268. var _ref = _asyncToGenerator(function* (destination) {
  269. if (destination instanceof Function) {
  270. yield destination({
  271. customMedia: getObjectWithStringifiedKeys(customExports.customMedia),
  272. customProperties: getObjectWithStringifiedKeys(customExports.customProperties),
  273. customSelectors: getObjectWithStringifiedKeys(customExports.customSelectors)
  274. });
  275. } else {
  276. // read the destination as an object
  277. const opts = destination === Object(destination) ? destination : {
  278. to: String(destination)
  279. }; // transformer for Exports into a JSON-compatible object
  280. const toJSON = opts.toJSON || getObjectWithStringifiedKeys;
  281. if ('customMedia' in opts || 'customProperties' in opts || 'customSelectors' in opts) {
  282. // write directly to an object as customProperties
  283. opts.customMedia = toJSON(customExports.customMedia);
  284. opts.customProperties = toJSON(customExports.customProperties);
  285. opts.customSelectors = toJSON(customExports.customSelectors);
  286. } else if ('custom-media' in opts || 'custom-properties' in opts || 'custom-selectors' in opts) {
  287. // write directly to an object as custom-properties
  288. opts['custom-media'] = toJSON(customExports.customMedia);
  289. opts['custom-properties'] = toJSON(customExports.customProperties);
  290. opts['custom-selectors'] = toJSON(customExports.customSelectors);
  291. } else {
  292. // destination pathname
  293. const to = String(opts.to || ''); // type of file being written to
  294. const type = (opts.type || path.extname(opts.to).slice(1)).toLowerCase(); // transformed Exports
  295. const customMediaJSON = toJSON(customExports.customMedia);
  296. const customPropertiesJSON = toJSON(customExports.customProperties);
  297. const customSelectorsJSON = toJSON(customExports.customSelectors);
  298. if (type === 'css') {
  299. yield writeExportsToCssFile(to, customMediaJSON, customPropertiesJSON, customSelectorsJSON);
  300. }
  301. if (type === 'js') {
  302. yield writeExportsToCjsFile(to, customMediaJSON, customPropertiesJSON, customSelectorsJSON);
  303. }
  304. if (type === 'json') {
  305. yield writeExportsToJsonFile(to, customMediaJSON, customPropertiesJSON, customSelectorsJSON);
  306. }
  307. if (type === 'mjs') {
  308. yield writeExportsToMjsFile(to, customMediaJSON, customPropertiesJSON, customSelectorsJSON);
  309. }
  310. }
  311. }
  312. });
  313. return function (_x17) {
  314. return _ref.apply(this, arguments);
  315. };
  316. }()));
  317. }
  318. /* Helper utilities
  319. /* ========================================================================== */
  320. function getObjectWithStringifiedKeys(object) {
  321. return Object.keys(object).reduce((objectJSON, key) => {
  322. objectJSON[key] = String(object[key]);
  323. return objectJSON;
  324. }, {});
  325. }
  326. function writeFile(to, text) {
  327. return new Promise((resolve, reject) => {
  328. fs.writeFile(to, text, error => {
  329. if (error) {
  330. reject(error);
  331. } else {
  332. resolve();
  333. }
  334. });
  335. });
  336. }
  337. function escapeForJS(string) {
  338. return string.replace(/\\([\s\S])|(')/g, '\\$1$2').replace(/\n/g, '\\n').replace(/\r/g, '\\r');
  339. }
  340. var postcss = postcss$1.plugin('postcss-preset-env', opts => {
  341. // initialize options
  342. const features = Object(Object(opts).features);
  343. const insertBefore = Object(Object(opts).insertBefore);
  344. const insertAfter = Object(Object(opts).insertAfter);
  345. const browsers = Object(opts).browsers;
  346. const stage = 'stage' in Object(opts) ? opts.stage === false ? 5 : parseInt(opts.stage) || 0 : 2;
  347. const autoprefixerOptions = Object(opts).autoprefixer;
  348. const sharedOpts = initializeSharedOpts(Object(opts));
  349. const stagedAutoprefixer = autoprefixerOptions === false ? () => {} : autoprefixer(Object.assign({
  350. overrideBrowserslist: browsers
  351. }, autoprefixerOptions)); // polyfillable features (those with an available postcss plugin)
  352. const polyfillableFeatures = cssdb.concat( // additional features to be inserted before cssdb features
  353. getTransformedInsertions(insertBefore, 'insertBefore'), // additional features to be inserted after cssdb features
  354. getTransformedInsertions(insertAfter, 'insertAfter')).filter( // inserted features or features with an available postcss plugin
  355. feature => feature.insertBefore || feature.id in plugins).sort( // features sorted by execution order and then insertion order
  356. (a, b) => idsByExecutionOrder.indexOf(a.id) - idsByExecutionOrder.indexOf(b.id) || (a.insertBefore ? -1 : b.insertBefore ? 1 : 0) || (a.insertAfter ? 1 : b.insertAfter ? -1 : 0)).map( // polyfillable features as an object
  357. feature => {
  358. // target browsers for the polyfill
  359. const unsupportedBrowsers = getUnsupportedBrowsersByFeature(feature.caniuse);
  360. return feature.insertBefore || feature.insertAfter ? {
  361. browsers: unsupportedBrowsers,
  362. plugin: feature.plugin,
  363. id: `${feature.insertBefore ? 'before' : 'after'}-${feature.id}`,
  364. stage: 6
  365. } : {
  366. browsers: unsupportedBrowsers,
  367. plugin: plugins[feature.id],
  368. id: feature.id,
  369. stage: feature.stage
  370. };
  371. }); // staged features (those at or above the selected stage)
  372. const stagedFeatures = polyfillableFeatures.filter(feature => feature.id in features ? features[feature.id] : feature.stage >= stage).map(feature => ({
  373. browsers: feature.browsers,
  374. plugin: typeof feature.plugin.process === 'function' ? features[feature.id] === true ? sharedOpts // if the plugin is enabled and has shared options
  375. ? feature.plugin(Object.assign({}, sharedOpts)) // otherwise, if the plugin is enabled
  376. : feature.plugin() : sharedOpts // if the plugin has shared options and individual options
  377. ? feature.plugin(Object.assign({}, sharedOpts, features[feature.id])) // if the plugin has individual options
  378. : feature.plugin(Object.assign({}, features[feature.id])) // if the plugin is already initialized
  379. : feature.plugin,
  380. id: feature.id
  381. })); // browsers supported by the configuration
  382. const supportedBrowsers = browserslist(browsers, {
  383. ignoreUnknownVersions: true
  384. }); // features supported by the stage and browsers
  385. const supportedFeatures = stagedFeatures.filter(feature => supportedBrowsers.some(supportedBrowser => browserslist(feature.browsers, {
  386. ignoreUnknownVersions: true
  387. }).some(polyfillBrowser => polyfillBrowser === supportedBrowser)));
  388. return (root, result) => {
  389. const majorVersion = parseInt(result.processor.version.split('.')[0]);
  390. if (majorVersion > 7) {
  391. console.log('');
  392. console.log(`
  393. ┌─────────────────────────────────────────────────────────────────────────────────┐
  394. │ │
  395. │ This version of postcss-preset-env is not optimised to work with PostCSS 8. │
  396. │ Please update to version 7 of PostCSS Preset Env. │
  397. │ │
  398. │ If you find issues, you can report it at: │
  399. │ https://github.com/csstools/postcss-plugins/issues/new/choose │
  400. │ │
  401. └─────────────────────────────────────────────────────────────────────────────────┘
  402. `);
  403. console.log('');
  404. } // polyfills run in execution order
  405. const polyfills = supportedFeatures.reduce((promise, feature) => promise.then(() => feature.plugin(result.root, result)), Promise.resolve()).then(() => stagedAutoprefixer(result.root, result)).then(() => {
  406. if (Object(opts).exportTo) {
  407. writeToExports(sharedOpts.exportTo, opts.exportTo);
  408. }
  409. });
  410. return polyfills;
  411. };
  412. });
  413. const initializeSharedOpts = opts => {
  414. if ('importFrom' in opts || 'exportTo' in opts || 'preserve' in opts) {
  415. const sharedOpts = {};
  416. if ('importFrom' in opts) {
  417. sharedOpts.importFrom = opts.importFrom;
  418. }
  419. if ('exportTo' in opts) {
  420. sharedOpts.exportTo = {
  421. customMedia: {},
  422. customProperties: {},
  423. customSelectors: {}
  424. };
  425. }
  426. if ('preserve' in opts) {
  427. sharedOpts.preserve = opts.preserve;
  428. }
  429. return sharedOpts;
  430. }
  431. return false;
  432. };
  433. module.exports = postcss;
  434. //# sourceMappingURL=index.js.map