/

  • Analyticsnpmv16.3.0

    • Overview
  • Apollonpmv15.2.1ESM

    • Overview
  • Browserslist-confignpmv15.2.1

    • Overview
  • CMSnpmv16.7.0

    • Overview
    • ContentBuilder
    • InviteUserForm
    • LoginForm
    • RenewPasswordForm
    • WysiwygInput
  • Corenpmv16.3.0

    • Overview
  • Core-Reactnpmv16.3.0

    • Overview
  • DataGridnpmv16.7.0

    • Overview
    • DataGrid
    • DataGridCustomExample
    • ExportButton
    • FilterList
    • Filters
    • FiltersButton
    • FulltextInput
    • HiddenColumns
    • HiddenColumnsButton
    • Pagination
    • RowCounts
    • RowsPerPageSelect
    • SelectedRowsToolbar
    • TableV2
    • ToolbarControl
    • ToolbarCustoms
    • ToolbarTabs
  • Datepickernpmv16.3.0

    • Overview
  • DnDnpmv15.2.1

    • Overview
  • E2E-Playwrightnpmv16.7.0

    • Overview
  • Eslint-confignpmv15.2.1

    • Overview
  • Formnpmv16.7.0

    • Overview
    • AvatarFileInput
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • ColorRadioGroup
    • Combobox
    • DatePickerInput
    • DateRangePickerInput
    • DatetimePickerInput
    • Dropzone
    • FileInput
    • Form
    • FormRenderer
    • GpsInput
    • MoneyInput
    • MultiCombobox
    • MultiSelect
    • NumberInput
    • PasswordInput
    • RadioGroup
    • Select
    • TextInput
    • Textarea
    • TimePickerInput
    • Toggle
  • Icons-generatornpmv16.3.0

    • Overview
  • Localizenpmv16.3.0

    • Overview
  • Mailingnpmv16.3.0

    • Overview
  • Oxc-confignpmv16.7.0

    • Overview
  • Page-Buildernpmv15.3.0ESM

    • Overview
  • Page-Builder-CMSnpmv16.7.0ESM

    • Overview
  • Page-Builder-Webnpmv16.7.0ESM

    • Overview
  • Postcss-confignpmv16.7.0

    • Overview
  • Resizernpmv15.2.1

    • Overview
  • Routernpmv16.3.0ESM

    • Overview
  • Scriptsnpmv16.7.0

    • Overview
  • Sentrynpmv16.4.0ESM

    • Overview
  • Smart-addressnpmv15.2.1

    • Overview
  • Stylelint-confignpmv16.4.0

    • Overview
  • Stylesnpmv16.3.0

    • Overview
  • UInpmv16.7.0

    • Overview
    • Accordion
    • AlertBubble
    • AnnouncementBar
    • Avatar
    • AvatarFileInput
    • Badge
    • Button
    • ButtonGroup
    • ButtonList
    • Calendar
    • Checkbox
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • Chip
    • ColorRadio
    • ColorRadioGroup
    • Combobox
    • DatePicker
    • DatePickerInput
    • DateRangePicker
    • DateRangePickerInput
    • DatetimePicker
    • DatetimePickerInput
    • Dialog
    • Dropdown
    • Dropzone
    • ErrorMessage
    • FileInput
    • FlashMessages
    • FormComponent
    • Icon
    • IconButton
    • ImageGallery
    • InfoBox
    • Input
    • Label
    • Layout
    • Lightbox
    • ListItem
    • Loader
    • Lozenge
    • Menu
    • Message
    • Modal
    • ModalDialog
    • ModalHeader
    • MultiCombobox
    • MultiSelect
    • Pagination
    • Paper
    • Popover
    • Radio
    • RadioGroup
    • RasterImage
    • Select
    • Switch
    • Tabs
    • TextInput
    • TextLink
    • Textarea
    • TimePicker
    • TimePickerInput
    • Toggle
    • Tooltip
    • Typography
  • Wysiwygnpmv16.7.0

    • Overview
Previous← Page-Builder-Web overviewNextResizer overview →

@uxf/postcss-config

npm

The PostCSS config of UXF frontend projects on Tailwind CSS 3 and Next.js: the postcss.config.js most projects carry byte for byte (108 of the 151 copies found in project checkouts). Most of the others add postcss-focus-visible in front.

What it runs

In this order:

  1. postcss-import: inlines the @imports, so that Tailwind sees one stylesheet. Without it the build fails on the first @apply of a class defined in another file (The uxf-typo-h6 class does not exist in @uxf/ui/css/message.css), with webpack and with Turbopack.
  2. tailwindcss/nesting: nested rules, before Tailwind expands @apply in them.
  3. tailwindcss: Tailwind CSS 3 with the project's tailwind.config.js.
  4. autoprefixer: vendor prefixes for the browserslist (@uxf/browserslist-config).
  5. postcss-pxtorem: every px value from 1 px up becomes rem, in every property, so that the page scales with the browser's font size.

Installation

yarn add -D @uxf/postcss-config
yarn dependencies:fix

Next.js resolves each plugin by its name from the project, not from this package, so the plugins are peer dependencies: autoprefixer, postcss, postcss-import, postcss-pxtorem and tailwindcss 3. A project with @uxf/scripts gets the missing ones from yarn dependencies:fix; the usual UXF project has all of them already.

Usage

// postcss.config.js
module.exports = require("@uxf/postcss-config");

A project that needs one more plugin spreads the config. Key order is plugin order, so a plugin that has to run first goes first:

// postcss.config.js
const uxfPostcssConfig = require("@uxf/postcss-config");

module.exports = {
    plugins: {
        "postcss-focus-visible": {},
        ...uxfPostcssConfig.plugins,
    },
};

Before keeping postcss-focus-visible, check whether the project still needs it: every browser of @uxf/browserslist-config supports :focus-visible, so the plugin only matters for CSS written against its polyfill (a .focus-visible class or [data-focus-visible-added]).

Measured

uxf-base/web built (next build --experimental-build-mode=compile) with its own postcss.config.js, with this package, and with one plugin left out at a time:

BuildWithout postcss-importWithout autoprefixer
webpack (--webpack, what UXF projects use for production)failsloses -webkit-backdrop-filter and -webkit-user-select, which Safari 17.4 still needs, and keeps a needless -webkit-box-shadow that autoprefixer removes
Turbopackfailsbyte for byte the same CSS: Turbopack prefixes for the browserslist on its own

With this package the webpack build wrote byte for byte the CSS of the project's own config.

Not here yet

  • Tailwind CSS 4. @tailwindcss/postcss inlines imports, nests and prefixes on its own, so the config shrinks to it and postcss-pxtorem. That is a major release of this package, together with @uxf/ui and @uxf/stylelint-config.
  • Dropping autoprefixer once projects build with Turbopack, where it changes nothing (above).