Theme Configuration
In MageObsidian Components, each compatible theme can include additional configurations by creating a configuration file at:
This file follows the CJS (CommonJS) format for compatibility reasons and exports a configuration object that 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.cjs
file might look like this:
Configuration Options
1. tailwind
- Type:
Object
- Default:
{}
- Description: Defines custom Tailwind CSS configurations for the theme. This can include
theme
,plugins
, andcontent
arrays. - Example:
For details on how to structure a Tailwind CSS configuration, refer to the official documentation:
Tailwind CSS Configuration
2. ignoredTailwindConfigFromModules
- Type:
Array
orString ('all')
- Default:
[]
- Description: Lists module-specific Tailwind configurations to ignore. If set to
'all'
, all module Tailwind configurations will be excluded.
3. ignoredCssFromModules
- Type:
Array
orString ('all')
- Default:
[]
- Description: Specifies modules whose CSS should be excluded from the final build. If set to
'all'
, all module CSS files will be excluded.
4. includeTailwindConfigFromParentThemes
- Type:
Boolean
- Default:
true
- Description: Determines whether the theme should inherit Tailwind configurations from its parent themes.
5. includeCssSourceFromParentThemes
- Type:
Boolean
- Default:
true
- Description: Determines whether the CSS source files from parent themes should be included in the final build.
6. 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.phtml
files 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 CSS or Tailwind configurations from specific modules—or all modules—can be excluded, keeping the final build clean and optimized. -
Tailwind Integration:
Themes can fully leverage Tailwind CSS for a utility-first approach, with complete control over its configuration. -
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 format is CJS to ensure compatibility across environments.
- Excluded CSS and Tailwind configurations from modules are ignored completely, reducing unnecessary styles.
- Exposing NPM packages as objects allows for precise integration with third-party libraries.
By leveraging this configuration system, MageObsidian Components ensures that themes remain powerful, customizable, and efficient for all frontend needs.