All files / packages/design-system-2/scripts/buildCss modular-theme-plugins.ts

100% Statements 2/2
100% Branches 3/3
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                                          15x                  
/**
 * The PostCSS plugin set for modular theme CSS.
 *
 * Shared by buildThemeLayer.buildModularThemes (cosmos, lightning-blue) and
 * buildPearl, so pearl processes its CSS identically to the standard themes.
 * The dist-only reject-theme-layer pass is appended when forDist is true.
 */
 
import type postcss from 'postcss';
import postcssAtImport from 'postcss-import';
import postcssNesting from 'postcss-nested';
import postcssRemoveComments from 'postcss-discard-comments';
import postCssDeprecatedSelector from '../plugins/postcss-deprecated-selector.ts';
import postCssScopeTokens from '../plugins/postcss-scope-tokens.ts';
import postCssHeaderComment from '../plugins/postcss-header-comment.ts';
import postcssRejectThemeLayer from '../plugins/postcss-reject-theme-layer.ts';
 
/**
 * Returns the PostCSS plugin set for modular theme CSS.
 * @param forDist - true for production (dist) builds; appends the reject-theme-layer pass.
 */
export const modularThemePlugins = (forDist = false): postcss.AcceptedPlugin[] => [
  postcssAtImport({ cache: false }),
  postcssRemoveComments(),
  postcssNesting(),
  postCssScopeTokens({ injectLayerOrder: false }),
  postCssDeprecatedSelector(),
  postCssHeaderComment(),
  ...(forDist ? [postcssRejectThemeLayer()] : []),
];