๋ฉ”์ธ ์ปจํ…์ธ ๋กœ ์ด๋™
๋ฒ„์ „: ๋ถˆ์•ˆ์ • ๐Ÿšง

๐Ÿ“ฆ plugin-css-cascade-layers

Experimental

This plugin is mostly designed to be used internally by the classic preset through the Docusaurus future.v4.useCssCascadeLayers flag, although it can also be used as a standalone plugin. Please let us know here if you have a use case for it and help us design an API that makes sense for the future of Docusaurus.

A plugin for wrapping CSS modules of your Docusaurus site in CSS Cascade Layers. This modern CSS feature is widely supported by all browsers. It allows grouping CSS rules in layers of specificity and gives you more control over the CSS cascade.

Use this plugin to:

  • apply a top-level @layer myLayer { ... } block rule around any CSS module, including un-layered third-party CSS.
  • define an explicit layer ordering
์ฃผ์˜

To use this plugin properly, it's recommended to have a solid understanding of CSS Cascade Layers, the CSS Cascade and specificity.

Installationโ€‹

npm install --save @docusaurus/plugin-css-cascade-layers
ํŒ

If you use the preset @docusaurus/preset-classic, this plugin is automatically configured for you with the siteConfig.future.v4.useCssCascadeLayers flag.

Configurationโ€‹

์„ค์ •ํ•  ์ˆ˜ ์žˆ๋Š” ํ•„๋“œ

์˜ต์…˜๋ช…ํƒ€์ž…๊ธฐ๋ณธ๊ฐ’์„ค๋ช…
layersLayersBuilt-in layersAn object representing all the CSS cascade layers you want to use, and whether the layer should be applied to a given file path. See examples and types below.

Typesโ€‹

Layersโ€‹

type Layers = Record<
string, // layer name
(filePath: string) => boolean // layer matcher
>;

The layers object is defined by:

  • key: the name of a layer
  • value: a function to define if a given CSS module file should be in that layer
Order matters

The object order matters:

  • the keys order defines an explicit CSS layer order
  • when multiple layers match a file path, only the first layer will apply

Example configurationโ€‹

You can configure this plugin through plugin options.

const options = {
layers: {
'docusaurus.infima': (filePath) =>
filePath.includes('/node_modules/infima/dist'),
'docusaurus.theme-classic': (filePath) =>
filePath.includes('/node_modules/@docusaurus/theme-classic/lib'),
},
};