Skip to content

Commit 1121eb8

Browse files
authored
Merge pull request #293 from hyva-themes/292-add-support-for-tailwind-config-merge
#292 Add support for automatic tailwind config merge
2 parents d0c94e4 + 390c3d7 commit 1121eb8

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Hyva\ReactCheckout\Observer;
5+
6+
use Magento\Framework\Component\ComponentRegistrar;
7+
use Magento\Framework\Event\Observer;
8+
use Magento\Framework\Event\ObserverInterface;
9+
10+
class RegisterModuleForHyvaConfig implements ObserverInterface
11+
{
12+
/**
13+
* @var ComponentRegistrar
14+
*/
15+
private $componentRegistrar;
16+
17+
public function __construct(ComponentRegistrar $componentRegistrar)
18+
{
19+
$this->componentRegistrar = $componentRegistrar;
20+
}
21+
22+
public function execute(Observer $event)
23+
{
24+
$config = $event->getData('config');
25+
$extensions = $config->hasData('extensions') ? $config->getData('extensions') : [];
26+
27+
$moduleName = implode('_', array_slice(explode('\\', __CLASS__), 0, 2));
28+
29+
$path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName);
30+
31+
// Only use the path relative to the Magento base dir
32+
$extensions[] = ['src' => substr($path, strlen(BP) + 1)];
33+
34+
$config->setData('extensions', $extensions);
35+
}
36+
}

src/etc/frontend/events.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
4+
<event name="hyva_config_generate_before">
5+
<observer name="hyva_react_checkout" instance="Hyva\ReactCheckout\Observer\RegisterModuleForHyvaConfig"/>
6+
</event>
7+
</config>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Since Hyvä Themes 1.1.14 this file is automatically
3+
* merged into your Hyvä Theme Tailwind config
4+
*
5+
* See https://docs.hyva.io/hyva-themes/compatibility-modules/tailwind-config-merging.html
6+
*
7+
**/
8+
9+
module.exports = {
10+
purge: {
11+
content: [
12+
'../../../reactapp/src/**/*.jsx',
13+
]
14+
}
15+
}

0 commit comments

Comments
 (0)