Skip to content

Commit 6729aec

Browse files
committed
#292 Add support for automatic tailwind config merge
1 parent f753873 commit 6729aec

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Hyvä Themes - https://hyva.io
4+
* Copyright © Hyvä Themes 2020-present. All rights reserved.
5+
* This product is licensed per Magento install
6+
* See https://hyva.io/license
7+
*/
8+
9+
declare(strict_types=1);
10+
11+
namespace Hyva\ReactCheckout\Observer;
12+
13+
use Magento\Framework\Component\ComponentRegistrar;
14+
use Magento\Framework\Event\Observer;
15+
use Magento\Framework\Event\ObserverInterface;
16+
17+
class RegisterModuleForHyvaConfig implements ObserverInterface
18+
{
19+
/**
20+
* @var ComponentRegistrar
21+
*/
22+
private $componentRegistrar;
23+
24+
public function __construct(ComponentRegistrar $componentRegistrar)
25+
{
26+
$this->componentRegistrar = $componentRegistrar;
27+
}
28+
29+
public function execute(Observer $event)
30+
{
31+
$config = $event->getData('config');
32+
$extensions = $config->hasData('extensions') ? $config->getData('extensions') : [];
33+
34+
$moduleName = implode('_', array_slice(explode('\\', __CLASS__), 0, 2));
35+
36+
$path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName);
37+
38+
// Only use the path relative to the Magento base dir
39+
$extensions[] = ['src' => substr($path, strlen(BP) + 1)];
40+
41+
$config->setData('extensions', $extensions);
42+
}
43+
}

src/etc/frontend/events.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Hyvä Themes - https://hyva.io
5+
* Copyright © Hyvä Themes 2020-present. All rights reserved.
6+
* This product is licensed per Magento install
7+
* See https://hyva.io/license
8+
*/
9+
-->
10+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
11+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
12+
<event name="hyva_config_generate_before">
13+
<observer name="hyva_react_checkout" instance="Hyva\ReactCheckout\Observer\RegisterModuleForHyvaConfig"/>
14+
</event>
15+
</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)