import type { MercuryBundleBase, MercuryBundleOptimized, MercuryBundleReset } from "@genexus/mercury"; import type { MercuryTokensDefinition } from "../tokens/_generated/mercury-generated-definition"; import type { MercuryCssDefinition } from "./mercury-css-definition"; /** * Configuration options for the Mercury build process, used in plugins and build tools. * * This interface provides a comprehensive set of settings to manage asset paths, * control cache-busting strategies via file hashing, and optimize initial load * performance through CSS inlining and preloading. It also allows for deep * customization of the design system through CSS and design token overrides. */ export type MercuryOptions = { /** * An object to customize the location of the Mercury assets (CSS, font, and * icon files) in the distribution build. * * In dev mode these files are proxied to the real source. */ assetsPaths?: MercuryOptionsAssets; /** * Customize which files are not hashed. * * **IMPORTANT!**: Use this field if you know what you are doing. Not hashing * the CSS files could lead to cache issues when changing the version of * Mercury. * * By default, all CSS bundle files are hashed to avoid any cache issue. */ avoidHash?: { [key in MercuryBundleBase | MercuryBundleReset | MercuryBundleOptimized]?: boolean; }; /** * Determine which CSS files will be inserted at the end of html `head` as a * `style` tag. In some cases, this may improve initial load performance; for * example, inlining the `base/base` bundle. * * **Warning**: Abusing of this setting could lead to diminishing returns. * * Due to the previous point, this setting does not allow inlining the * `base/icons` CSS bundle, as it is a relatively big file that could bloat the * initial HTML size. * * By default, the `base/base` and `resets/box-sizing` CSS bundles are inlined. */ cssInline?: { [key in Exclude | MercuryBundleReset | MercuryBundleOptimized]?: boolean; }; /** * Determine which CSS files will be preloaded as a `` tag. * In some cases, this may improve initial load performance. * * When using `true` the default config will be `{ position: "head", fetchPriority: "auto" }` * * **Warning**: Abusing of this setting could lead to diminishing returns. * * By default, the `"base/icons"` CSS bundle is preloaded at the `"body-end"` * position with `fetchPriority: "low"`. */ cssPreload?: { [key in MercuryBundleBase | MercuryBundleReset | MercuryBundleOptimized]?: MercuryOptionsAssetPreload; }; /** * Allows customizing Mercury's design system through CSS bundle and design * token overrides. * * This object provides a way to deeply customize the appearance and behavior * of Mercury components by overriding CSS bundles and design tokens. * Use this to adapt Mercury to your specific design requirements without * modifying the core library. */ overrides?: { /** * Allows overriding specific CSS bundles used by Mercury. * * All css bundles can be overridden, but it's recommended to only override * those that are necessary to achieve the desired customization. */ css?: MercuryCssDefinition; /** * Allows overriding specific design tokens used by Mercury. * * All tokens can be overridden (primitives and semantics), but it's * recommended to only override those that are necessary to achieve the * desired customization. */ tokens?: MercuryTokensDefinition; }; /** * The theme variant in which Mercury is implemented. * * @default "mercury" */ theme?: "mercury" | "globant"; }; export type MercuryOptionsAssets = { /** * Path where the CSS files of Mercury are located in the distribution build. * * @default "/assets/css/" */ cssPath?: string; /** * Path where the font files of Mercury are located in the distribution build. * * @default "/assets/fonts/" */ fontsPath?: string; /** * Path where the icon files of Mercury are located in the distribution build. * * @default "/assets/icons/" */ iconsPath?: string; }; export type MercuryOptionsAssetPreload = boolean | { /** * The position where the link is placed. * - `"head"`: Places the `` at the end of the html `head`. * - `"body-start"`: Places the `` at the start of the html `body`. * - `"body-end"`: Places the `` at the end of the html `body`. * * @default "head" */ position?: "head" | "body-start" | "body-end"; /** * Represents a hint to the browser indicating how it should prioritize * fetching a particular resource relative to other resources of the same * type. * * Based on [fetchPriority](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/fetchPriority). * * @default "auto" */ fetchPriority?: "auto" | "high" | "low"; };