Theme Configuration¶
In MageObsidian Components, each compatible theme can include additional configurations by creating a configuration file at:
This file is an ESM (ECMAScript module) that export defaults a configuration object MageObsidian Components uses to customize and control the theme’s behavior.
How It Works¶
-
Configuration File Location
The theme configuration file should be placed in the following path relative to your theme’s directory: -
Example Configuration File
A basic example of atheme.config.jsfile might look like this:
Tailwind tokens live in CSS, not here. With Tailwind 4 the theme's design tokens are declared in
web/css/theme.source.css(@theme { … }), sotheme.config.jscarries only the build options below. See CSS Configuration.
Configuration Options¶
1. ignoredCssFromModules¶
- Type:
ArrayorString ('all') - Default:
[] - Description: Specifies modules whose CSS should be excluded from the final build. If set to
'all', all module CSS files are excluded.
2. includeCssSourceFromParentThemes¶
- Type:
Boolean - Default:
true - Description: Determines whether the CSS source files from parent themes should be included in the final build.
3. exposeNpmPackages¶
- Type:
Array of Objects - Default:
[] -
Description: Allows specific NPM packages to be exposed for use in the theme's frontend JavaScript. Each object in the array must define:
exposePath: The exposed path for importing the package.package: The actual NPM package name.
-
Usage in Templates:
Exposed libraries can be easily accessed in.phtmlfiles using the$block->getViewLibFileUrl()method. For example: -
Example:
Benefits of Theme Configuration¶
-
Customizability:
Themes can define their own configurations, ensuring flexibility for frontend behavior and design. -
Inheritance:
Parent themes can pass down configurations to child themes, simplifying setup and maintaining consistency. -
Exclusion Control:
Unwanted module CSS—from specific modules or all of them—can be excluded, keeping the final build clean and optimized. -
NPM Package Integration:
Exposing NPM packages simplifies dependency management, allowing themes to directly use third-party libraries. These can be included in templates using$block->getViewLibFileUrl().
Key Notes¶
- The configuration file is an ESM module (
export default), consistent with the ESM-only build engine. - Excluded module CSS is ignored completely, reducing unnecessary styles.
- Exposing NPM packages as objects allows for precise integration with third-party libraries.
- Tailwind tokens are configured CSS-first in
web/css/theme.source.css(@theme), not in this file.
By leveraging this configuration system, MageObsidian Components ensures that themes remain powerful, customizable, and efficient for all frontend needs.