-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#292 Add support for automatic tailwind config merge
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Hyvä Themes - https://hyva.io | ||
* Copyright © Hyvä Themes 2020-present. All rights reserved. | ||
* This product is licensed per Magento install | ||
* See https://hyva.io/license | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Hyva\ReactCheckout\Observer; | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
use Magento\Framework\Event\Observer; | ||
use Magento\Framework\Event\ObserverInterface; | ||
|
||
class RegisterModuleForHyvaConfig implements ObserverInterface | ||
{ | ||
/** | ||
* @var ComponentRegistrar | ||
*/ | ||
private $componentRegistrar; | ||
|
||
public function __construct(ComponentRegistrar $componentRegistrar) | ||
{ | ||
$this->componentRegistrar = $componentRegistrar; | ||
} | ||
|
||
public function execute(Observer $event) | ||
{ | ||
$config = $event->getData('config'); | ||
$extensions = $config->hasData('extensions') ? $config->getData('extensions') : []; | ||
|
||
$moduleName = implode('_', array_slice(explode('\\', __CLASS__), 0, 2)); | ||
|
||
$path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName); | ||
|
||
// Only use the path relative to the Magento base dir | ||
$extensions[] = ['src' => substr($path, strlen(BP) + 1)]; | ||
|
||
$config->setData('extensions', $extensions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Hyvä Themes - https://hyva.io | ||
* Copyright © Hyvä Themes 2020-present. All rights reserved. | ||
* This product is licensed per Magento install | ||
* See https://hyva.io/license | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> | ||
<event name="hyva_config_generate_before"> | ||
<observer name="hyva_react_checkout" instance="Hyva\ReactCheckout\Observer\RegisterModuleForHyvaConfig"/> | ||
</event> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Since Hyvä Themes 1.1.14 this file is automatically | ||
* merged into your Hyvä Theme Tailwind config | ||
* | ||
* See https://docs.hyva.io/hyva-themes/compatibility-modules/tailwind-config-merging.html | ||
* | ||
**/ | ||
|
||
module.exports = { | ||
purge: { | ||
content: [ | ||
'../../../reactapp/src/**/*.jsx', | ||
] | ||
} | ||
} |